Created with <3 with dartpad.dev.
Created
October 24, 2023 02:49
-
-
Save leonus96/b2ff2f2314b12e4f07a706662778330c to your computer and use it in GitHub Desktop.
funciones
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// FUNCIONES !!! | |
| /// 1. Las funciones permiten encapsular | |
| /// un conjunto de instrucciones | |
| /// en un bloque reutilizable. | |
| /// 2. Pueden aceptar parámetros de entrada. | |
| /// 3. Pueden devolver un valor como resultado | |
| /// (o simplemente ejecutar un conjunto de | |
| /// instrucciones sin retorno). | |
| /// 4. Las funciones se llaman invocándolas | |
| // por su nombre seguido de paréntesis. | |
| /// SINTAXIS: | |
| /// tipoDeRetorno nombreDeLaFuncion (parametros) { | |
| /// -- Código de la función -- | |
| /// | |
| /// return valorDeRetorno; (Opcional) | |
| /// } | |
| /// void ==> No retorna nada | |
| /// COMO LLAMO UNA FUNCIÓN: | |
| /// nombreDeLaFuncion(parametros); | |
| void main() { | |
| print(suma(5, 10)); | |
| } | |
| // Ej1: void sin params | |
| void saludar() { | |
| print('Hola usuario'); | |
| } | |
| // Ej2: void con parametro | |
| void saludarUsuario(String nombre) { | |
| print('Hola $nombre'); | |
| } | |
| // Ej3: int con parametros | |
| int suma(int a, int b) { | |
| final resultado = a + b; | |
| return resultado; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment