Advertisement
ZEdKasat

Dart Baiscs

Jan 15th, 2022
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.73 KB | None | 0 0
  1. void main() {
  2.   int age = 23;
  3.   String name = "Bruce";
  4.  
  5.   print('My name is ${name} and I am ${age} years old.');
  6.  
  7. //   for x in range(10)
  8. //   for(initialization; condition; increment)
  9.   for(int i = 0; i < 10; i = i+2){
  10.     print(i);
  11.   }
  12.  
  13.   if(10 >= 12){
  14.     print("Good");
  15.   }else{
  16.     print("Bad");
  17.   }
  18.  
  19. //   while(condition){
  20. //     content;
  21. //   }
  22.   int my_age = getAge(2008);
  23.   print(my_age);
  24. }  //main
  25.  
  26. // int getAge(){
  27. //    int birth_year = 1997;
  28. //    int current_year = 2022;
  29. //    return current_year-birth_year;
  30. //  }
  31.  
  32.  
  33. // def getAge(birth_year):
  34. //   return 2022-birth_year
  35.  
  36.  
  37. // int getAge(int birth_year){
  38. //   return 2022-birth_year;
  39. // }
  40.  
  41. int getAge(int birth_year) => 2022-birth_year;
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement