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

UFO演算子について

 UFO演算子について

RubyKaigi 2016 After Party (2016-09-10)

Hirofumi Wakasugi

September 11, 2016
Tweet

More Decks by Hirofumi Wakasugi

Other Decks in Programming

Transcript

  1. 6'0
    ԋࢉࢠ
    ʹ͍ͭͯ
    (What's the Story) Spaceship Operator?
    Hirofumi Wakasugi (@5t111111)

    View full-size slide

  2. ϓϩάϥϚʔ
    Hirofumi Wakasugi (@5t111111)

    View full-size slide

  3. 4QBDFTIJQ0QFSBUPS

    DMBTT4J[F.BUUFST
    JODMVEF$PNQBSBCMF
    EFGJOJUJBMJ[F TUS

    !TUSTUS
    FOE

    EFG PUIFS

    TUSTJ[FPUIFSTUSTJ[F
    FOE
    FOE
    w #BTJDPQFSBUPSGPSDPNQBSJOHUIFSFDFJWFSBHBJOTUBOPUIFSPCKFDU
    w "MTPLOPXOBTl6'0PQFSBUPSz MFBTUJO+BQBO

    w $MBTTFTNJYJOT$PNQBSBCMFNVTUJNQMFNFOU

    View full-size slide

  4. *NQMFNFOUBUJPOPG
    w1PTJUJWFOVNCFSJGTFMGJTHSFBUFSUIBOPUIFS
    w;FSPJGTFMGJTFRVBMUPPUIFS
    w/FHBUJWFOVNCFSJGTFMGJTMFTTUIBOPUIFS
    DMBTT'PP
    ǘ
    EFG PUIFS

    SFUVSOJGTJ[FPUIFSTJ[F
    SFUVSOJGTJ[FPUIFSTJ[F
    SFUVSOJGTJ[FPUIFSTJ[F
    FOE
    FOE
    GPPGPPUSVFGBMTF
    *UTIPVMESFUVSO

    View full-size slide

  5. w :PVDBOXSJUFMJLFUIJTVTJOHJUTJNQMFNFOUBUJPO
    w -PPLTQSFUUZDPOWFOJFOU EPFTO`UJU
    "UJQGPSVTJOH
    DBTF GPPCBS

    XIFO
    QVUTGPPJTFRVBMUPCBS
    XIFO
    QVUTGPPJTHSFBUFSUIBOCBS
    FMTF
    QVUTGPPJTMFTTUIBOCBS
    FOE

    View full-size slide

  6. w :PVDBOXSJUFMJLFUIJTVTJOHJUTJNQMFNFOUBUJPO
    w -PPLTQSFUUZDPOWFOJFOU EPFTO`UJU
    "UJQGPSVTJOH
    DBTF GPPCBS

    XIFO
    QVUTGPPJTFRVBMUPCBS
    XIFO
    QVUTGPPJTHSFBUFSUIBOCBS
    FMTF
    QVUTGPPJTMFTTUIBOCBS
    FOE
    ʁʁ

    (SFBUFSJGQPTJUJWF
    0SMFTTJGQPTUJWF
    0SQPTJUJWFJGQPTJUJWF
    85'

    View full-size slide

  7. 4P*BMXBZTEPUIFGPMMPXJOHTUFQTXIFO*
    XBOUUPVTFDPNQBSJTPOPQFSBUPSTXJUINZ
    DMBTTFT
    *ODMVEFUIFNPEVMFJOBDMBTT
    4UBSUXSJUJOHAEFG PUIFS
    FOEA
    CFBOHVJTIFEUSZJOHUPSFNJOENFUPJGHSFBUFSMFTT
    NVTUSFUVSOQPTJUJWFOFHBUJWFOVNCFS
    (PPHMJOHGPSBXIJMF
    *UEPFTOPUXPSLʜ
    6IPI*JODMVEF&OVNFSBCMFJOTUFBEPG$PNQBSBCMF

    View full-size slide

  8. 4P*UIJOL*NQMFNFOUBUJPOPG
    FYDFQUJPOBMMZMBDLTEFTDSJQUJWFQPXFS
    JO3VCZXPSME
    almost seems like magic numbers

    View full-size slide

  9. *USFNJOETNFPGTPNFUIJOHMJLF
    JOUDPNQBSF@JOU DPOTUWPJEB DPOTUWPJEC

    \
    SFUVSO JOU
    B JOU
    C
    ^
    JOUNBJO

    \
    JOUEBUB<>\ ^
    RTPSU EBUB TJ[FPG JOU
    DPNQBSF@JOU

    ^
    w 0METDIPPM$JTIqBWPS
    w +BWB DPNQBSF5P
    /&5 $PNQBSF5P

    View full-size slide

  10. w *UXPVMECFFBTJFSUPLOPXUIFDPEFT`JOUFOTJPO
    *BNTVSFZPVDBOVTFJGʜFMTJGʜUIPVHI

    *XJTI*DPVMEXSJUFMJLF
    DBTFGPPCBS
    XIFO&2
    QVUTGPPJTFRVBMUPCBS
    XIFO(5
    QVUTGPPJTHSFBUFSUIBOCBS
    FMTF
    QVUTGPPJTMFTTUIBOCBS
    FOE

    View full-size slide

  11. )BTLFMM
    DMBTT&RB0SEBXIFSF
    DPNQBSFBB0SEFSJOH
    EBUB0SEFSJOH-5]&2](5
    ADPNQBSFA
    -5
    0SE
    0SEFSJOH
    DPNQBSFSFUVSOT0SEFSJOH
    3VTU
    QVCFOVN0SEFSJOH\
    -FTT
    &RVBM
    (SFBUFS
    ^
    0SEFSJOH
    MFUSFTVMUDNQ

    BTTFSU@FR 0SEFSJOH-FTT SFTVMU

    MFUSFTVMUDNQ

    BTTFSU@FR 0SEFSJOH&RVBM SFTVMU

    DNQSFUVSOT0SEFSJOH

    View full-size slide

  12. w 3BOHFVTJOH*/'*/*5:XPVMEXPSLXJUIDBTFFYQSFTTJPO
    8IBUJGZPVTJNQMZVTFDPOTUBOUT
    NPEVMF0SEFSJOH
    (5'MPBU*/'*/*5:
    -5'MPBU*/'*/*5:
    &2
    FOE
    DBTFGPPCBS
    XIFO0SEFSJOH&2
    QVUTGPPJTFRVBMUPCBS
    XIFO0SEFSJOH(5
    QVUTGPPJTHSFBUFSUIBOCBS
    XIFO0SEFSJOH-5
    QVUTGPPJTMFTTUIBOCBS
    FOE

    View full-size slide

  13. w *UEPFTOPUXPSLCFDBVTFPGUIFJSUZQFT
    w .BZCFJUIBTTPNFPWFSIFBE
    8IBUJGUIFTFDPOTUBOUTBSF
    BWBJMBCMFJOHMPCBMOBNFTQBDFʜ
    EFG PUIFS

    JGTJ[FPUIFSTJ[F
    0SEFSJOH(5
    FMTJGTJ[FPUIFSTJ[F
    0SEFSJOH&2
    FMTF
    0SEFSJOH-5
    FOE
    FOE

    View full-size slide

  14. *BNTVSFJNQMFNFOUBUJPOSFRVJSFNFOU
    PGMFUTZPVUPXSJUFMJLF
    EFG PUIFS

    TJ[FPUIFSTJ[F
    FOE
    *MPWFUIJTBTJUJTDMFBOBOEDPODJTFFOPVHI BTMPOH
    BTZPVVOEFSTUBOEJUTSFRVJSFNFOUDPSSFDUMZ

    View full-size slide

  15. w*OBMNPTUBMMDBTFTUIFJNQMFNFOUBUJPOUIBU
    SFUVSOTOOJTFOPVHIBOEBMTPIBTBEWBOUBHF
    w.PSFEFTDSJQUJWFPQUJPOTXPVMECFWFSZXFMDPNF
    FTQFDJBMMZGPSOFXCJFT
    w*EPO`UIBWFBOZHPPEJEFBTZFU DPOTJEFSJOHJG
    TJOHMFUPOPCKFDUTMJLFOJMUSVFGBMTFXPSL

    $PODMVTJPO

    View full-size slide

  16. 5)"/,:06
    w"MM3VCZ,BJHJTUB⒎TBOETQFBLFST
    w"MMSVCZJTUT*IBWFOFWFSFWFSNFU
    w XJUIFNQIBTJT
    %SFDPN3VCZ,BSBPLFXBTKVTU&1*$
    ʜBOE!.BLF/PX+VTUGPSHJWJOHNFJOTQJSBUJPO IUUQT
    HJUIVCDPNDSZTUBMMBOHDSZTUBMQVMM

    *XPVMEBMTPMJLFUPTBZUIBOLZPVUP

    View full-size slide