Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Global
- var Name: String? = null
- fun main() {
- MyName()
- Testing()
- }
- fun MyName() {
- Name = "Mikasa"
- // Local
- var car = "BMW"
- println("nama: $Name car $car")
- }
- fun Testing() {
- var a = 10
- if (a == 10) {
- var b = 5
- println("b: $b")
- }
- // println("b: $b")
- // Error: out of coverage/scope
- }
- /* Variable Scope = coverage of variable
- * Scope: Global & Local
- * */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement