Answer Posted / Ankur Bhardwaj
The '█' parameter in Ruby is a shorthand syntax for defining block methods. It allows you to define a method that can be passed as a block of code to other methods. The '&' symbol is used to reference this block in the method definition.nFor example:nndef sum(&block)n block.call(1) { |num| num + 2 } # This calls the block with argument 1 and expects it to return a number that will be added by 2.nendnsum do |number|n number * numbernend
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers