Norway


learning kotlin – visibility modifiers, internal modifier, modules – fragmented - fragmented logo wp post header copy 825x510 - Learning Kotlin – visibility modifiers, internal modifier, modules – Fragmented

Another day, another opportunity to learn more . In this episode, Kaushik walks through the concept of . How do the in Kotlin differ from the ones in Java? What is this new ? When should I use each of the operators?

Listen on to find out!

Direct download

learning kotlin – visibility modifiers, internal modifier, modules – fragmented - Evernote Snapshot 20171026 075041 - Learning Kotlin – visibility modifiers, internal modifier, modules – Fragmented

  • Excellent resource explaining visibility modifiers in Kotlin

    open class Outer {
        private val a = 1
        protected open val b = 2
        internal val c = 3
        val d = 4  // public by default
    
        protected class Nested {
            public val e: Int = 5
        }
    }
    
    class Subclass : Outer() {
        // a is not visible
        // b, c and d are visible
        // Nested and e are visible
    
        override val b = 5   // 'b' is protected
    }
    
    class Unrelated(o: Outer) {
        // o.a, o.b are not visible
        // o.c and o.d are visible (same module)
        // Outer.Nested is not visible, and Nested::e is not visible either 
    }
    



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here