Advertisement
Guest User

Untitled

a guest
Jul 10th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.05 KB | None | 0 0
  1. void main() {
  2.  
  3.   add();
  4.   addNumber(3,11);
  5.   int number  = returnSumNumber(5,5);
  6.   print(number);
  7.   functionArrow(2,2);
  8.   int multiplicacion = retornarSuma(3,3);
  9.   print(multiplicacion);
  10.  
  11.  
  12.   List list = ["Rojo","Azul","Verde"];
  13.  
  14.   list.forEach((val){
  15.     if(val == "Verde"){
  16.       print(val);
  17.     }
  18.   });
  19.  
  20.  
  21.   parametrosRequeridos(1,2);
  22.   parametrosOpcionales(1);
  23.   parametrosOpcionalesDefinidos(3,b:5);
  24.  
  25.  
  26.  
  27. }
  28. //funciones!!
  29. void add(){
  30.   print(3+5);
  31. }
  32.  
  33. void addNumber(int a, int b){
  34.   print(a+b);
  35. }
  36.  
  37. int returnSumNumber(int a, int b){
  38.   return a+b;
  39. }
  40.  
  41. void functionArrow(int a, int b) => print("el resultado sera ${a*b}");
  42. int retornarSuma(int a, int b) => a*b;
  43.  
  44. //parametros
  45. void parametrosRequeridos (int a,int  b){
  46.   print("parametro 1: ${a}");
  47.   print("parametro 2: ${b}");
  48. }
  49. void parametrosOpcionales (int a,[int  b]){
  50.   print("parametro 1: ${a}");
  51.   print("parametro 2: ${b}");
  52. }
  53. void parametrosOpcionalesDefinidos (int a,{int  b=10}){
  54.   print("parametro 1: ${a}");
  55.   print("parametro 2: ${b}");
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement