+ 2
Is there any difference between 'Proc' and 'proc'?
In the ex: greet = Proc.new do |x| puts "Welcome #{x}" end goodbye = Proc.new do |x| puts "Goodbye #{x}" end def say(arr, proc) arr.each { |x| proc.call x} people = ["David", "Amy", "John"] say(people, greet) say(people, goodbye) If i am changing any 'proc' to 'Proc' or vice-versa then it's showing error. Please someone guide me. Thanks
6 Respuestas
+ 8
Ruby is a sensitive cased language which means case and Case are not the same, Its the same when declaring a variable, or getting the Proc. You cant just do proc.new do instead you need Proc.new do :D
+ 5
proc is a parameter of the functions "say" so it is not a Proc.:D
+ 5
My pleasure :D
+ 3
MrCoder, oh ya i got it now, Thanks (y)
+ 2
MrCoder Thanks for your answer but they used 'Proc' and 'proc' in the same program. Why so?
0
Proc is a class, it's a constant, proc is just a parameter.