问题
Is possible to use method proc with parameters in Crystal ?
Something like:
def foo(baz)
puts "#{baz} foo!"
end
proc = ->foo
proc.call "Hi"
回答1:
Yes. If the method has arguments, you must specify their types:
proc = ->foo(String)
proc.call "Hi" # Hi foo!
Find more examples at crystal docs.
来源:https://stackoverflow.com/questions/46728581/method-proc-with-parameters