Skip to content

Instantly share code, notes, and snippets.

@davidmigloz
Last active April 22, 2021 08:06
Show Gist options
  • Save davidmigloz/a30cf88007622eb8e78deef1611133d4 to your computer and use it in GitHub Desktop.
Save davidmigloz/a30cf88007622eb8e78deef1611133d4 to your computer and use it in GitHub Desktop.
Dart vs Kotlin: variables and constants
void main() {
// Mutable variable
String explicitMutableVariable = "Hey!";
var implicitMutableVariable = "Hey!";
// Immutable variable (runtime constant)
final String explicitImmutableVariable = "Hey!";
final implicitImmutableVariable = "Hey!";
// Compile time constant
const String explicitConstant = "Hey!";
const implicitConstant = "Hey!";
// Nullable variable
String? nullableVariable = null;
}
fun main() {
// Mutable variable
var explicitMutableVariable : String = "Hey!"
var implicitMutableVariable = "Hey!"
// Immutable variable (runtime constant)
val explicitImmutableVariable: String = "Hey!"
val implicitImmutableVariable = "Hey!"
// Nullable variable
var nullableVariable: String? = null
}
// Compile time constant
const val EXPLICIT_CONSTANT: String = "Hey!"
const val IMPLICIT_CONSTANT = "Hey!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment