Last active
April 22, 2021 08:06
-
-
Save davidmigloz/a30cf88007622eb8e78deef1611133d4 to your computer and use it in GitHub Desktop.
Dart vs Kotlin: variables and constants
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
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; | |
} |
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
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