I have the following construct (simplified):
puts ['a!', 'b!', 'c?'].select { |f| f if f.end_with?('!') }
It prints
a!
b!
I want to use an ampersand to make it even shorter:
puts ['a!', 'b!', 'c?'].select(&:end_with?('!'))
But I get an error:
..., 'c?'].select(&:end_with?('!'))
_
x.rb:4: syntax error, unexpected ')', expecting end-of-input
How can I solve this?