Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Kotlinでマッチョ💪💪💪💪💪する話

operandoOS
December 09, 2016

 Kotlinでマッチョ💪💪💪💪💪する話

Kotlinでマッチョ💪💪💪💪💪する話

Retty Tech Cafe #8
https://retty.connpass.com/event/45628/

operandoOS

December 09, 2016
Tweet

More Decks by operandoOS

Other Decks in Technology

Transcript

  1. Triple΋͋ΔΑ val triple = Triple(1, true, "Triple") println(triple.first) // 1

    println(triple.second) // true println(triple.third) // Triple
  2. Pair͔ΒTripleΛ࡞Δ֦ுؔ਺Λॻ͍ͯΈͨ infix fun <A, B, C> Pair<A, B>.to(that: C)
 :

    Triple<A, B, C> = 
 Triple(this.first, this.second, that)
  3. ͡ΌtoͰͭͳ͛ͯॻ͍ͯΈΑ͏ val triple = 1 to true to "Triple" println(triple.first)

    // 1 println(triple.second) // true println(triple.third) // Triple println(triple.javaClass) // class kotlin.Triple
  4. 4ͭͷ஋Λ࣋ͭTuple QuartetΛ࡞Ζ͏ class Quartet<out F, out S, out T, out

    FO>( val first: F, val second: S, val third: T, val fourth: FO,) { override fun toString(): String { return "Quartet(first=$first, second=$second,
 third=$third, fourth=$fourth)" } }
  5. Triple͔ΒQuartetΛ࡞Δ֦ுؔ਺Λॻ͘ infix fun <A, B, C, D> Triple<A, B, C>.to(that:

    D): Quartet<A, B, C, D> = 
 Quartet(this.first, this.second, this.third, that)
  6. Quartet࢖ͬͯΈΑ͏ val quartet = 1 to 10L to true to

    "quartet" println(quartet.first) // 1 println(quartet.second) // 10 println(quartet.third) // true println(quartet.fourth) // quartet
  7. 5ͭͷ஋Λ࣋ͭTuple QuintetΛ࡞Ζ͏ class Quintet<out F, out S, out T, out

    FO, out FI>( val first: F, val second: S, val third: T, val fourth: FO, val five: FI) { override fun toString(): String { return "Quintet(first=$first, second=$second,
 third=$third, fourth=$fourth, five=$five)" } }
  8. ͸͍͸͍ɺ֦ுؔ਺֦ுؔ਺ infix fun <A, B, C, D, E> Quartet<A, B,

    C, D>.to(that: E): Quintet<A, B, C, D, E> = Quintet(this.first, this.second, this.third, this.fourth, that)
  9. Quintet࢖ͬͯΈΑ͏ val quintet = 1 to 10L to true to

    LocalDateTime.now() to "quintet" println(quintet.first) // 1 println(quintet.second) // 10 println(quintet.third) // true println(quintet.fourth) // 2016-12-09T19:45:38.959 println(quintet.five) // quintet
  10. Links • Pair͔ΒTripleΛ࡞Δ֦ுؔ਺Λॻ͍ͯΈͨ - 2016/12/03ͷ30෼ KotlinϝϞ • http://hack-it-iron.hatenablog.com/entry/2016/12/03/165601 • 4ͭͱ5ͭ஋Λ࣋ͭTupleΛ࡞ͬͯΈͨ

    - 2016/12/04ͷ30෼ KotlinϝϞ • http://hack-it-iron.hatenablog.com/entry/2016/12/04/223509 • TupleϥΠϒϥϦ GuildͷKotlin൛࡞ͬͯΈͨ - 2016/12/09ͷ30෼ KotlinϝϞ • http://hack-it-iron.hatenablog.com/entry/2016/12/09/172657 • Guild • https://github.com/operando/Guild/