Skip to content

Instantly share code, notes, and snippets.

@murajun1978
Created February 25, 2014 15:27
Show Gist options
  • Save murajun1978/9211070 to your computer and use it in GitHub Desktop.
Save murajun1978/9211070 to your computer and use it in GitHub Desktop.
# "0:Ruby" "1:mruby" "2:RubyMotion"
%w(Ruby mruby RubyMotion).each_with_index do |name, index|
puts "#{index}:#{name}"
end #=> ["Ruby", "mruby", "RubyMotion"]
# "1:Ruby" "2:mruby" "3:RubyMotion"
%w(Ruby mruby RubyMotion).each.with_index(1) do |name, index|
puts "#{index}:#{name}"
end #=> ["Ruby", "mruby", "RubyMotion"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment