ãã¨ãã°æ´æ°ã®é åãããæ¡ä»¶ã«åãè¦ç´ ã®ãã¡ãæåã«ç¾ãã 10 åã ãæ¾ãããã¨ããã©ããã¾ããï¼ ary.select {|x| x.even? }.take(10) âããã¯é常ã«æçãªããã°ã©ã ã§ããããã select ã¯ãæåã® 10 åã ãã§ãªãå ¨è¦ç´ ããã§ãã¯ãã¦ãã¾ããããary ã大ããã¨ç¡é§ã«ã«ã¼ããã¾ããã¾ããselect ã®æ»ãå¤ã¨ãªãä¸éé åãç¡é§ã§ãã ret = [] ary.each do |x| ret << x if x.even? break if ret.size == 10 end âãããªã 10 åè¦ã¤ãã£ãæç¹ã§çµäºãã¦ãããããç¡é§ãªé å確ä¿ãããã¾ããããããé常ã«å¼·å¼ã§åå§çã§ç ©éãªããã°ã©ã ã§ãããRuby 1.9 ã®æ代ãè¿ããæ°äººé¡ã§ããæã ã«ã¯ãå¯èªæ§ãã¡ã³ããã³ã¹æ§ã«åé¡ãããã¨è¨ããããå¾ãªããä¸è¨ã§è¨ãã¨åããªãã®ã§ãã
{{#tags}}- {{label}}
{{/tags}}