Created with <3 with dartpad.dev.
Created
October 17, 2023 02:56
-
-
Save leonus96/ffb220677c3cc6aec104e898991d753c to your computer and use it in GitHub Desktop.
tipos-de-variables
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
void main() { | |
/// TIPOS DE VARIABLES | |
// +++++++++++++++++++++++++++ | |
/// variable (var): Se pueden reasignar. | |
/// var a = 50; | |
/// a = 80; | |
/// a = 0; | |
/// int b = 10; | |
// +++++++++++++++++++++++++++ | |
/// final: No se puede reasignar: | |
/// Ejemplo 1: | |
/// final double pi = 3.14; | |
/// final double radio = 5; | |
/// final double area = pi * radio * radio; | |
/// print(area); | |
/// Nota: Siempre usar final, | |
/// hasta que obligatoriamente, tengamos que reasignar un valor. | |
/// Ejemplo 2 | |
/// final String nombre = 'Joseph'; | |
/// final String apellido = 'Leon'; | |
/// print('Mi nombre es: $nombre $apellido'); | |
/// Ejemplo 3 | |
/// int suma = 0; | |
/// final int valor1 = 5; | |
/// final int valor2 = 10; | |
/// final int valor3 = 6; | |
/// suma = valor1 + valor2; | |
/// suma = suma + valor3; | |
/// print(suma); | |
// +++++++++++++++++++++++++++ | |
/// const: no se puede reasignar, se inicializan | |
/// al principio del programa. | |
/// const double pi = 3.14; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment