String sayHello(String name){
return "Hello $name nice to meet you";
}
void main(){
print(sayHello('성연'));
}
String sayHello(String name) => "Hello $name nice to meet you";
void main(){
print(sayHello('성연'));
}
String sayHello(String name) => "Hello \$name nice to meet you, $name";
void main(){
print(sayHello('성연'));
}
//Positional parameter
String sayHello(String name, int age, String country){
return "Hi, my name is $name and im $age years old, im come from $country";
}
void main(){
print(sayHello('성연',24,'Korea'));
}
required
추가//required 사용 예시
String sayHello({required String name, required int age, required String country}){
return "Hi, my name is $name and im $age years old, im come from $country";
}
void main(){
print(sayHello(name:'성연',age: 24, country: 'korea'));
}
//default value 지정 경
String sayHello({String name = '성연', int age = 25, String country = 'korea'}){
return "Hi, my name is $name and im $age years old, im come from $country";
}
void main(){
print(sayHello(name:'성연',age: 24));
}
출력값을 구하시오(??과 ?=차이점)
void main() {
String? name;
String greeting = 'Hello, ${name ?? "Guest"}!';
print(greeting);
print(name);
}
void main() {
int? x;
int y = 10;
x ??= y;
print(x);
}