File: closure.rbi

package info (click to toggle)
nqp 2016.12%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 7,960 kB
  • ctags: 3,884
  • sloc: java: 25,027; perl: 910; makefile: 12; sh: 2
file content (10 lines) | stat: -rw-r--r-- 281 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
def gen_times(factor)
    lambda {|n| n*factor }
end

times3 = gen_times(3)      # 'factor' is replaced with 3
times5 = gen_times(5)

puts "3 X 12      = #{times3.call( 12 )}"
puts "5 X 5       = #{times5.call( 5 )}"
puts "3 X (5 X 4) = #{times3.call( times5.call(4) )}"