Call method from parameter : Method Arguments « Method « Ruby
- Ruby
- Method
- Method Arguments
Call method from parameter
def endless_string_succession(start)
while true
yield start
start = start.succ
end
end
endless_string_succession('fol') do |x|
puts x
break if x[-1] == x[-2]
end
# fol
# fom
# fon
# foo
Related examples in the same category