ãã£ã¨æ©ãç¥ãããã£ã⦠ã£ã¦ãã¨Rubyã¨ãRailsã¨ãå¤ãã§ãããã ç¥ããªãã£ããã©ä¾¿å©ã¯ã©ã¹ãã¡ã½ããããã£ããã ãã¿ãããªã ä¾ãã°Rubyã§é åã®ä¸èº«ãé çªã«è¡¨ç¤ºããã¨ããeach使ã£ãããã¾ãããï¼ list = [a,b,c] list.each { |val| puts val } ã§ãã¤ã³ããã¯ã¹ãä¸ç·ã«ä½¿ãããã£ã¦æ㯠each_with_index使ã£ã¦ã¾ããã list = [a,b,c] list.each_with_index { |val, index| puts "#{index + 1}çªç®ã®å¤ã¯#{val}ã§ã" } ã¤ã³ããã¯ã¹ã¯åå¾ã§ãããã§ããã©ãã ã¤ã³ããã¯ã¹ã£ã¦0ããå§ã¾ãã®ã§ãä¸è¨ã®ããã«nçªç®ãã¿ãããªã®ãåºããã¨æã㨠index + 1ããªãããããªããã§ãããã ããããã â¦ã¨æã£ã¦ããã with_index ã¨ããã¡ã½ãã
{{#tags}}- {{label}}
{{/tags}}