Created
March 21, 2019 10:03
-
-
Save samanzamani/273b206a094e796caa344430c2433146 to your computer and use it in GitHub Desktop.
Sample class and function in Dart
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 MyClass{ | |
String str = ''; | |
MyClass(this.str); | |
} | |
void main() { | |
MyClass obj1 = MyClass('obj1 initial'); | |
print(obj1.str); | |
doSomething(obj1); | |
print(obj1.str); | |
obj1 = doSomethingElse(obj1); | |
print(obj1.str); | |
} | |
void doSomething(MyClass obj){ | |
obj.str = 'obj1 new string'; | |
} | |
MyClass doSomethingElse(MyClass obj){ | |
return MyClass('obj1 new object'); | |
//OR => return obj..str = "obj1 new object"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment