Add a variable to a class instance at runtime: Difference between revisions
Content added Content deleted
(→{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details) |
|||
Line 617: | Line 617: | ||
val name = readLine()!! |
val name = readLine()!! |
||
val value = sc.runtimeVariables[name] |
val value = sc.runtimeVariables[name] |
||
if (value == null) |
if (value == null) { |
||
println("There is no variable of that name, try again") |
println("There is no variable of that name, try again") |
||
else { |
} else { |
||
println("Its value is '${sc.runtimeVariables[name]}'") |
println("Its value is '${sc.runtimeVariables[name]}'") |
||
return |
return |