스터디27 [Dart] #3.1 Named Parameters ({ }) 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.. 2024. 1. 10. [Dart] #3.0 Functions void V_sayHello(String name){ //void means this funtion doesn't return anything print("hello $name nice to meet you"); } String S_sayHello(String name){ return "hello $name nice to meet you"; } String S2_sayHello(String name) => "hello $name nice to meet you" //fat arrow syntax. immediate return. use when your function only has one line code. //don't have to use Curly Brakets void main() { print.. 2024. 1. 10. [Dart] #2.5 Sets var numbers = {1,2,3,4}; //Set Set numbers = {1, 2, 3, 4}; //values in Set are all Unique. values in List don't have to be Unique. List numbers2 = [1, 2, 3, 4, 1, 1, 1]; 2024. 1. 10. [Dart] #2.4 Maps //Maps are something like Dictionary in PTYHON! var player = { 'name' : 'nico', 'xp' : 19.99, 'superpower' : false, }; //this is Maps //Object means baiscally ANY type. Map player = { 1: true, 2: false, 3: true }; Map player = { [1,2,3,4] : true, }; List players = [ { 'name' : 'nico', 'xp' : 1999.999 }, { 'name' : 'nico', 'xp' : 1999.999 }, ]; *movies, players 같이 key와 value 형태로 구성된 정보를 Api로 부터 받.. 2024. 1. 10. [Dart] #2.3 Collection For var oldFriends = ['nico', 'lynn']; var newFriends = [ 'lewis', 'ralph', 'darren', for(var friend in oldFriends) "♥ $friend", ]; print(newFriends); collection if : 로그인 여부에 따라 상단바 다르게 하고 싶을 때! collection for : 여러 값 반복 add() 하는거를 한번에! 2024. 1. 10. [Dart] #2.2 String interpolation '$' var name = 'nico'; var age = 10; var greeting = 'Hello everyone, my name is $name, and I am ${age +2}'; //$ is String Interpolation 2024. 1. 10. 이전 1 2 3 4 5 다음