Skip to content

Instantly share code, notes, and snippets.

@tgautier
Created October 23, 2014 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgautier/6a9f6a65543c8b828590 to your computer and use it in GitHub Desktop.
Save tgautier/6a9f6a65543c8b828590 to your computer and use it in GitHub Desktop.
Faker method to illustrate blocks @lewagon
def fake_complexity(number)
puts "Launching very smart computation with the most clever algorithm...."
sleep(1)
puts ".."
sleep(1)
puts "...."
sleep(1)
puts "......."
result = yield(number, 4)
puts "Pfiou... That was some hard mathematics.."
return result
end
sum = fake_complexity(6) do |num, factor|
num * factor
end
puts sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment