Rubyã«ããã¦ã·ã¼ã±ã³ã¹ãã¤ã¾ãæå³çã«é£ç¶ããè¦ç´ ã®ä¸¦ã³ãç°¡åã«çæããObject#repeatã¨ãããã®ãèãã¾ãããï¼ä»¥åã«èããEnumerable#repeatãåã«ãã¹ã¦ã®ãªãã¸ã§ã¯ãã«æ¡å¼µãããã®ã§ããã©ã class Object def repeat(init=true, &blk) x = self Enumerator.new do |y| y << x if init loop { y << (x = yield x) } end end end repeatã¯ããã®ã¬ã·ã¼ããªãã¸ã§ã¯ããåæå¤ã¨ãã¦ã渡ããããããã¯ãç¹°ãè¿ãé©ç¨ãã¾ããé©ç¨ã®çµæã¯Enumeratorãªãã¸ã§ã¯ãã§ã©ããããã¦ããã®ã§ãé 延è©ä¾¡ããã¾ãã 以ä¸ã«ãåé¡ã«çããå½¢ã§ä½¿ãæ¹ãè¦ãã¾ãããæ¯è¼ã®ããrepeatã使ããªãæ¹æ³ãé©å®ç¤ºãã¾ãã 1. åé 1ãå ¬å·®2ã®çå·®æ°åã®æåã®2
{{#tags}}- {{label}}
{{/tags}}