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

私とUnityとLINQと

 私とUnityとLINQと

# 私とUnityとLINQと

## @RyotaMurohoshi
### 2014/12/20 プログラミング生放送勉強会 第32回

※もともとはSlideShareで公開していた資料です

RyotaMurohoshi

December 20, 2014
Tweet

More Decks by RyotaMurohoshi

Other Decks in Technology

Transcript

  1. RPGͷϓϨΠϠʔΛ࢘Δɺ͜ΜͳΫϥε͕͋Δͱͯ͠ɺ public class Player { public int HP { get;

    set; } public string Name { get; set; } /* ଞͳΜ͔͍Ζ͍Ζ */ }
  2. LINQΛ࢖͏ͱίʔυ͕୹͘ͳΔʂ ਺͑Δ෦෼͸6ߦ // LINQΛ࢖Θͳ͍ͱ List<Player> playerList = GetPlayerList (); int

    deadPlayerCount = 0; foreach (Player player in playerList) { if(player.HP <= 0) { deadPlayerCount++; } }
  3. LINQΛ࢖͏ͱίʔυ͕୹͘ͳΔʂ // LINQΛ࢖Θͳ͍ͱ int deadPlayerCount = 0; foreach (Player player

    in playerList) { if(player.HP <= 0) { deadPlayerCount++; } } // LINQΛ࢖͏ͱ int deadPlayerCount = playerList.Count (player => player.HP <= 0);
  4. ͜ͷίʔυɺͲ͏ಡΈ·͢ʁ // LINQΛ࢖Θͳ͍ͱ List<Player> playerList = GetPlayerList (); int deadPlayerCount

    = 0; foreach (Player player in playerList) { if(player.HP <= 0) { deadPlayerCount++; } }