crystal
crystal copied to clipboard
Compiler doesn't understand block when using brackets
(Apologies if this has already been filed, but it's difficult to search for)
The parser does not like block arguments on the var[] syntax. Example:
class Test
def [](key, &block)
yield
end
end
t = Test.new
t["test"] { puts "test" }
Same with do...end. The t.[]("test") { puts "test" } it's sugar for, works fine, but that's pretty ugly in my opinion.
For the record, this works in Ruby