Given a module Bam, and assuming that method Bam.[] is defined, the [] method can be called with a block in non-syntax sugar form like:
Bam.[]('boom') do |a|
puts a
end
How can I call the [] method with a block in syntax sugar form Bam['boom']?
I tried the following:
Bam['boom'] do |a|
puts a
end
Bam['boom'] {|a|
puts a
}
They raise a syntax error.
I'm not looking for naming alternatives to []. Ruby provides nice syntactic sugar, so I prefer [] over other names.