Use Proc.new to create a new method : Procs « Method « Ruby
- Ruby
- Method
- Procs
Use Proc.new to create a new method
log = Proc.new { |str| puts "[LOG] #{str}" }
log.call("A test log message.")
# [LOG] A test log message.
Related examples in the same category