8 Kotlin Pop Quizzes

8 Kotlin Pop Quizzes

979d93b360f80486b121486a9d063ad5?s=128

Hiroshi Kurokawa

August 22, 2017
Tweet

Transcript

  1. 8 Kotlin Pop Quizzes 4VNNFS,PUMJO-5.BUTVSJ
 )JSPTIJ,VSPLBXB !IZESBDLFDBU

  2. 2 Rules ⿣ $PEFTOJQQFUJTTIPXO ⿣ "OTXFSJOTFDPOET ⿣ "MMUIFDPNQJMFFSSPSTJGBOZ ⿣ 8IBUJTUIFPVUQVUTPSFSSPSTEJTQMBZFE

  3. 4FD 3 Quiz 1. fun sum(a: Int, b: Int) =

    { a + b } println(sum(1, 1))     
  4. 4 Quiz 1. fun sum(a: Int, b: Int) = {

    a + b } println(sum(1, 1)) 'VODUJPOKBWBMBOH*OUFHFS IUUQTLPUMJOMBOHPSHEPDTSFGFSFODF GVODUJPOTIUNMTJOHMFFYQSFTTJPOGVODUJPOT
  5. 5 Quiz 1. fun sum(a: Int, b: Int) = a

    + b println(sum(1, 1)) 'VODUJPOKBWBMBOH*OUFHFS IUUQTLPUMJOMBOHPSHEPDTSFGFSFODF GVODUJPOTIUNMTJOHMFFYQSFTTJPOGVODUJPOT
  6. 6 Quiz 1. fun sum(a: Int, b: Int) = a

    + b println(sum(1, 1))  IUUQTLPUMJOMBOHPSHEPDTSFGFSFODF GVODUJPOTIUNMTJOHMFFYQSFTTJPOGVODUJPOT
  7. 7 Quiz 2. (1..5).forEach({ i -> if (i > 3)

    return println(i) }) println("Done") 4FD     
  8. 8 Quiz 2. (1..5).forEach({ i -> if (i > 3)

    return println(i) }) println("Done")    IUUQTLPUMJOMBOHPSHEPDTSFGFSFODFJOMJOF GVODUJPOTIUNMOPOMPDBMSFUVSOT
  9. 9 Quiz 3. val ___ = 010 println(val) 4FD 

       
  10. val ___ = 010 println(val) 10 Quiz 3. &SSPS6OFYQFDUFEUPLFOT VTFUPTFQBSBUFFYQSFTTJPOTPOUIFTBNFMJOF

     &SSPS6OTVQQPSUFE<MJUFSBMQSFYFTBOETVYFT> &SSPS/BNFT@ @@ @@@  BSFSFTFSWFEJO,PUMJO @ @@ @@@ ʜBSFSFTFSWFEWBSJBCMFOBNFT %FDJNBMMJUFSBMDBOOPUTUBSUXJUIb` IUUQKFUCSBJOTHJUIVCJPLPUMJOTQFD@JEFOUJpFST IUUQKFUCSBJOTHJUIVCJPLPUMJOTQFD@EFDJNBM@MJUFSBMT
  11. 11 Quiz 4. open class A(val x: Any?) object B

    : A(C) object C : A(B) println(B.x) println(C.x) 4FD     
  12. 12 Quiz 4. open class A(val x: Any?) object B

    : A(C) object C : A(B) println(B.x) println(C.x) $!GFG OVMM IUUQKFUCSBJOTHJUIVCJPLPUMJOTQFD@TJOHMFUPO@PCKFDUT
  13. 13 Quiz 5. println(Unit is Unit) println(null is Any) println(null!!

    is Nothing) 4FD     
  14. 14 Quiz 5. USVF GBMTF &YDFQUJPOJOUISFBENBJOLPUMJO,PUMJO/VMM1PJOUFS&YDFQUJPO IUUQKFUCSBJOTHJUIVCJPLPUMJOTQFD@QSJNJUJWF@BOE@TQFDJBM@UZQFT println(Unit is Unit)

    println(null is Any) println(null!! is Nothing)
  15. 15 Quiz 6. class A { init { f() .}

    val a = "a" fun f() { println(a) } } A() 4FD     
  16. OVMM 16 Quiz 6. class A { init { f()

    䠼} val a = "a" fun f() { println(a) 䠼} 䠼} A() IUUQRJJUBDPNPNPDIJNFUBSVJUFNTCBBCGGF
  17. OVMM 17 Quiz 6. class A { val a =

    "a" init { f() 䠼} fun f() { println(a) 䠼} 䠼} A() IUUQRJJUBDPNPNPDIJNFUBSVJUFNTCBBCGGF
  18. B 18 Quiz 6. class A { val a =

    "a" init { f() 䠼} fun f() { println(a) 䠼} 䠼} A() IUUQRJJUBDPNPNPDIJNFUBSVJUFNTCBBCGGF
  19. 19 Quiz 7. println(127 as Int? === 127 as Int?)

    println(128 as Int? === 128 as Int?) 4FD     
  20. 20 Quiz 7. println(127 as Int? === 127 as Int?)

    println(128 as Int? === 128 as Int?) USVF GBMTF IUUQTTUBDLPWFSqPXDPNB
  21. 21 Quiz 8. println(2.5 in 1..3) println(3.5 in 1..3) 4FD

        
  22. 22 Quiz 8. println(2.5 in 1..3) println(3.5 in 1..3) USVF

    USVF IUUQTZPVUSBDLKFUCSBJOTDPNJTTVF,5
  23. 23 Thanks *GZPVBSFJOUFSFTUFEJO SFBE IUUQKFUCSBJOTHJUIVCJPLPUMJOTQFD :PVXJMMLOPXJUJTOPUUIBUTJNQMF