Class: Proc

Inherits:
Object
  • Object
show all
Defined in:
lib/lab42/stream/proc.rb

Instance Method Summary collapse

Instance Method Details

#memoizedObject



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/lab42/stream/proc.rb', line 2

def memoized
  already_run = false
  result      = nil
  ->{
    if already_run
      result
    else
      already_run = true
      result = call()
    end
  }
end