I find that the space between & and % is not required, and the compiler parses it well. Therefore my problem here is already solved, but I just want to know the reason.
I’m pretty sure having a space after the & is not valid syntax, hence the error. Same problem happens with your macro example (assuming you actually use the macro), see Carcin.
i don’t crystal a lot an just discover this syntax. i try to play with
it and noticed that
foo = -> {1}
bar = -> (&) {yield}
doesn’t work. did i miss something ? do that because one of the most
frustration to me with crystal (i had the same with ruby) is this
“shell alike block” finished by “end”. it would be nice to to brace
our functions (even by abusing the Proc syntax?) … something like
def bar(&) {
puts "i wanna yield"
yield
}
# or
def bar -> (&) {
puts "i wanna yield"
yield
}
# looks cleaner to me than
def bof(&)
puts "i wanna yield"
yield
end