스터디/Dart
[Dart] #3.1 Named Parameters ({ })
by SayHiWorld
2024. 1. 10.
String sayHello4({String name, int age, String country}){
return "Hello $name, you are $age, and you come from $country";
}
String sayHello2({
String name = 'anon',
int age = 99,
String country = 'wakanda',
}){
return "Hello $name, you are $age, and you come from $country";
}
String sayHello3({
required String name,
required int age,
required String country,
}){
return "Hello $name, you are $age, and you come from $country";
}
void main() {
print(sayHello('nico',19,'cuba')); //Not Good! what is nico? what is 19?
print(sayHello4(
age:12,
country:'cuba',
name:'nico',
));
print(sayHello2(
age:12,
));
}