Created
April 3, 2018 05:57
-
-
Save webcoderph/b906238d1a2cd687c52b548410ed8a2a to your computer and use it in GitHub Desktop.
Ruby Memoization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test(input) | |
@input ||= input | |
puts "TEST #{@input}" | |
end | |
alice = "im alice" | |
veronica = "im veronica" | |
thr = [] | |
thr << Thread.new { test(alice) } | |
thr << Thread.new { test(veronica) } | |
thr.each { |t| t.join } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment