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

Ruby講義 第5回

Ruby講義 第5回

Array, Hash

Kuniaki IGARASHI

May 10, 2012
Tweet

More Decks by Kuniaki IGARASHI

Other Decks in Technology

Transcript

  1. ഑ྻ "SSBZ ڭՊॻ Qʙ ΄͔ͷΦϒδΣΫτͷೖΕ΋ͷ ࡞Γํͷྫɿ OBNFT<zޒेཛྷz zᖛ࡚z> OVNCFST< 

    > <ͱ>Ͱғ͍ Ͱ۠੾Δɻ จࣈྻ΍਺ࣈ΄͔ɺͲΜͳΦϒδΣΫτ΋ೖΓ·͢ɻ ۭͬΆͷ഑ྻ͸<>Ͱ͢ɻ ֓೦ਤ͸ڭՊॻQਤΛࢀরɻ
  2. ഑ྻ "SSBZ ͷԋश ഑ྻ<  >ͷશཁૉΛදࣔ͢ΔίʔυΛॻ͍ͯ ͍ͩ͘͞ɻ ഑ྻ<  >ͷશཁૉΛՃ͑ͨ݁ՌΛදࣔ͢Δ

    ίʔυΛॻ͍͍ͯͩ͘͞ɻ ώϯτ͋Δม਺ʹ਺/Λ଍͢ͷ͸YY /Ͱ͢ɻ͜Ε͸Y /ͱ΋ॻ͚·͢ɻ
  3. ഑ྻ "SSBZ ͷԋशʲ্ڃʳ ʲ্ڃʳ഑ྻ<    >Λ<  >ʹ͢Δίʔ

    υΛߦͰॻ͍͍ͯͩ͘͞ɻ ώϯτɿϦϑΝϨϯεͰ"SSBZͷϝιουΛ୳ͯ͠Έ·͠ΐ͏ɻ IUUQNJZBNBFHJUIVCDPNSVCZEPDKB ʲ্ڃʳ্هΛFBDIΛ࢖Θͣʹॻ͍͍ͯͩ͘͞ ώϯτɿJOKFDUΛ࢖͍·͢ɻ࢖͍ํ͸ϦϑΝϨϯε͔Β୳͠·͠ΐ͏ɻ IUUQNJZBNBFHJUIVCDPNSVCZEPDKB
  4. ϋογϡ )BTI ڭՊॻ Qʙ Ωʔͱ஋ͷ૊Λ࣋ͯΔΦϒδΣΫτͷೖΕ ΋ͷɻͳΜͰ΋ೖΓ·͢ɻ ࡞Γํͷྫɿ SFDJQF\ UJUMF—೔޲ՆͷδϟϜ— BVUIPSᖛ࡚^

    \^Ͱғ͏ɹΩʔ஋ɹ۠੾Γ͸ ɹۭ഑ྻ͸\^ ͜͜ͰΩʔʹ࢖ΘΕ͍ͯΔ࢝·Γͷ΋ͷ͸Կʁ ɹˢΩʔˢ஋
  5. )BTIͷԋश ϋογϡͷશཁૉΛද ࣔ͢ΔɺӈͷίʔυΛ࣮ ߦ͍ͯͩ͘͠͞ɻ SFDJQF\ UJUMF͍ͪ͝ͷίϯϑΟ  BVUIPSᖛ࡚^ SFDJQFFBDIEPcL Wc

    QSJOUL  W aO FOE ͷίʔυதͷSFDJQFͷBVUIPSΩʔʹରԠ ͢Δ஋Λޒेཛྷͱ͢Δ୅ೖจΛॻ͍͍ͯͩ͘͞ɻ
  6. ഑ྻ "SSBZ ͷԋश ഑ྻ<  >ͷશཁૉΛදࣔ͢ΔίʔυΛॻ͍ͯ ͍ͩ͘͞ɻ ഑ྻ<  >ͷશཁૉΛՃ͑ͨ݁ՌΛදࣔ͢Δ

    ίʔυΛॻ͍͍ͯͩ͘͞ɻ ώϯτ͋Δม਺ʹ਺/Λ଍͢ͷ͸YY /Ͱ͢ɻ͜Ε͸Y /ͱ΋ॻ͚·͢ɻ ʲ্ڃʳ഑ྻ<    >Λ<  >ʹ͢Δίʔ υΛߦͰॻ͍͍ͯͩ͘͞ɻ ώϯτɿϦϑΝϨϯεͰ"SSBZͷϝιουΛ୳ͯ͠Έ·͠ΐ͏ɻ IUUQNJZBNBFHJUIVCDPNSVCZEPDKB ʲ্ڃʳ্هΛFBDIΛ࢖Θͣʹॻ͍͍ͯͩ͘͞ ώϯτɿJOKFDUΛ࢖͍·͢ɻ࢖͍ํ͸ϦϑΝϨϯε͔Β୳͠·͠ΐ͏ɻ IUUQNJZBNBFHJUIVCDPNSVCZEPDKB
  7. ഑ྻ "SSBZ ͷԋशղ౴ BSSBZ<  > BSSBZFBDIEPcYc QVUTY FOE ഑ྻ<

     >ͷશཁૉΛදࣔ͢ΔίʔυΛ ॻ͍͍ͯͩ͘͞ɻ
  8. ഑ྻ "SSBZ ͷԋशղ౴ TVN BSSBZ<  > BSSBZFBDIEPcYc TVNTVN Y

    FOE QVUTTVN ഑ྻ<  >ͷશཁૉΛՃ͑ͨ݁ՌΛදࣔ͢Δ ίʔυΛॻ͍͍ͯͩ͘͞ɻ ώϯτ͋Δม਺ʹ਺/Λ଍͢ͷ͸YY /Ͱ͢ɻ͜Ε͸Y /ͱ΋ॻ͚·͢ɻ
  9. ഑ྻ "SSBZ ͷԋशղ౴ Q<    >VOJR ഑ྻதͷॏෳΛআ͖ɺ֤஋ͭͣͭʹ͢Δʹ͸ "SSBZVOJRΛ࢖͍·͢ɻ

    IUUQNJZBNBFHJUIVCDPNSVCZEPDKB NFUIPEBSSBZJVOJRIUNM ʲ্ڃʳ഑ྻ<    >Λ<  >ʹ͢Δίʔ υΛߦͰॻ͍͍ͯͩ͘͞ɻ ώϯτɿϦϑΝϨϯεͰ"SSBZͷϝιουΛ୳ͯ͠Έ·͠ΐ͏ɻ IUUQNJZBNBFHJUIVCDPNSVCZEPDKB
  10. ഑ྻ "SSBZ ͷԋशղ౴ Q<  >JOKFDU  \cTVN JcTVN J^

    JOKFDU͸ศརͰ͔͍͍ͬ͜ϝιουͰ͢ɻ IUUQNJZBNBFHJUIVCDPNSVCZEPDKB NFUIPEFOVNFSBCMFJSFEVDFIUNM ͪͳΈʹɺͳͥ"SSBZΫϥεͷϝιουͰ͸ͳ͍JOKFDUΛ࢖͑Δ͔ͱ ͍͏ͱɺ"SSBZ͸&OVNFSBCMFͱ͍͏Ϟδϡʔϧͷϝιου΋࢖͑ Δ͔ΒͰ͢ɻ"SSBZ͚ͩͰͳ͘ɺFBDIΛ࣋ͭશͯͷΫϥε͸ &OVNFSBCMFΛ࢖͏͜ͱ͕Ͱ͖·͢ɻ ʲ্ڃʳ্هΛFBDIΛ࢖Θͣʹॻ͍͍ͯͩ͘͞ ώϯτɿJOKFDUΛ࢖͍·͢ɻ࢖͍ํ͸ϦϑΝϨϯε͔Β୳͠·͠ΐ͏ɻ IUUQNJZBNBFHJUIVCDPNSVCZEPDKB
  11. )BTIͷԋश ʲ্ڃʳӈͷOVNTΛ஋͕ۮ਺ͷ ཁૉ͚ͩʹ͍ͯͩ͘͠͞ɻ ώϯτɿϦϑΝϨϯεͰ)BTIͷϝιουΛ୳ͯ͠Έ·͠ΐ͏ɻ IUUQNJZBNBFHJUIVCDPNSVCZEPDKB ৒༨ ׂΓࢉͨ͠༨Γ ΛٻΊΔԋࢉࢠ͸Ͱ͢ɻ ϋογϡͷશཁૉΛද ࣔ͢ΔɺӈͷίʔυΛ࣮

    ߦ͍ͯͩ͘͠͞ɻ SFDJQF\ UJUMF͍ͪ͝ͷίϯϑΟ  BVUIPSᖛ࡚^ SFDJQFFBDIEPcL Wc QSJOUL  W aO FOE ͷίʔυதͷSFDJQFͷBVUIPSΩʔʹରԠ ͢Δ஋Λޒेཛྷͱ͢Δ୅ೖจΛॻ͍͍ͯͩ͘͞ɻ OVNT\ B C D E F^