Created
January 5, 2021 02:12
-
-
Save gavr123456789/1a07652d48d4cf3147aee7b629895551 to your computer and use it in GitHub Desktop.
Create an instance of type from type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Customer: Object { | |
private string _firstName; | |
private string _surname; | |
public string firstName { | |
set { _firstName = value; prin(_firstName); } | |
} | |
public string surName { | |
set { _surname = value; prin(_surname); } | |
} | |
} | |
T sas<T>(Type type){ | |
if (type.is_object()){ | |
var z = Object.new(type); | |
return z; | |
} else { | |
T t = 0; | |
return t; | |
} | |
} | |
void main() { | |
Customer cust = sas(typeof(Customer)); | |
cust.firstName = "sus"; | |
cust.surName = "ses"; | |
int a = sas(typeof(int)); | |
prin(a); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think there's an error in line 16: