Impressing Ruby example
ruby
Solution
I would highly suggest something with `.each`, `.inject` and/or `.collect`. For instance:
# Sum 1,3,5,7,9,11,13
[1,3,5,7,11,13].inject { |a,b| a+b }
or
# Print out all of the files in a directory
Dir.glob('./my_cool_directory/*').each do |file|
puts file
end
or
# Find the length of all of the strings
["test", "hello there", "how's life today?"].collect{ |string| string.length }
Problem
in some days I am giving a talk about a Rails project at university and I want to introduce the audience to Ruby. I want to show them one or two really nice code examples to demonstrate how awesome Ruby is. Do you know a good example? Best regards