Created with <3 with dartpad.dev.
Created
February 7, 2023 03:38
-
-
Save randy-johnson/c1920c3ffdba5ec476d087ce4b638d80 to your computer and use it in GitHub Desktop.
quintessential-utopia-9882
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 Person { | |
String? name; | |
int? age; | |
//// adding {} allows us to use named arguments | |
//@required does not work in plain dart | |
Person({@required String? name, @required int? age}){ | |
this.name = name; | |
this.age = age; | |
} | |
} | |
int addNumbers(int num1, int num2) { | |
return num1 + num2; | |
} | |
void main() { | |
var p1 = Person(name: 'Randy', age: 44); | |
var p2 = Person(name: 'Mandy',age: 25); | |
print(p1); | |
print(p1.name); | |
print(p1.age); | |
print(p2.name); | |
print(p2.age); | |
int firstResult = addNumbers(1, 23); | |
int secondResult = addNumbers(6, 7); | |
print(firstResult); | |
print(secondResult); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment