본문 바로가기
스터디/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,
        
	));
}

'스터디 > Dart' 카테고리의 다른 글

[Dart] #3.3 Optional Positional Parameters  (0) 2024.01.10
[Dart] #3.2 Recap ^_^ (positional,named,required,default)  (0) 2024.01.10
[Dart] #3.0 Functions  (0) 2024.01.10
[Dart] #2.5 Sets  (0) 2024.01.10
[Dart] #2.4 Maps  (1) 2024.01.10