Created
February 6, 2025 19:00
-
-
Save VictorAlemanHidalgo/ada24df84efc000e540a76893f61c8f4 to your computer and use it in GitHub Desktop.
Funcion con parametros opcionales
This file contains 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
// Parametros opcionales posicionales | |
void saludar(String nombre, [String? mensaje]) { | |
print('Hola $nombre, ${mensaje ?? ''}'); | |
} | |
void mostrarDatos({String? nombre, int? edad}) { | |
print("¡Hola, ${nombre}. Tu edad es: ${edad}!"); | |
} | |
void main() { | |
print(" Victor Aleman Hidalgo 20308051281123 "); | |
saludar("Victor"); | |
saludar("Victor", "Como estas?"); | |
mostrarDatos(nombre: "Victor", edad: 12); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Salida
![image](https://private-user-images.githubusercontent.com/179508129/410601107-c6dfd0df-57ad-4ffc-aabe-828d8437ce7d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzMTQyNDYsIm5iZiI6MTczOTMxMzk0NiwicGF0aCI6Ii8xNzk1MDgxMjkvNDEwNjAxMTA3LWM2ZGZkMGRmLTU3YWQtNGZmYy1hYWJlLTgyOGQ4NDM3Y2U3ZC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjExJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMVQyMjQ1NDZaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT02MTkwNDBjOTNiMGYwMzFhNWEzMDc0ZmI2MmZmMzBmMTc3MDMyYzU0OTZkODUxMjYyZmFhOWQ4ZTFmYTdjODY4JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.TZbRrdtywJunXQeyCGHZAUHI60yQ7aHoidK5ggOiEUc)