What would be the correct way to write this macro? My intention is to just wrap some logging statements in a conditional that would not be included when --no-debug is passed to the compiler.
macro debug(args)
{% if flag?(:debug) %}
puts {{ args }}
{% end %}
end
debug "Hello" # => Hello
debug [1,2,3] # => [1, 2, 3]
debug [1,2,3].map { |r| r.to_s }.join(", ") # => Error: 'Array(Int32)#map' is expected to be invoked with a block, but no block was given
debug([1,2,3].map { |r| r.to_s }.join(", ")) # => Error: 'Array(Int32)#map' is expected to be invoked with a block, but no block was given
Is this possibly an error in parsing argument precedence with macros?
Thank you!