Skip to content

Instantly share code, notes, and snippets.

@dnovais
Created January 21, 2022 17:49
Show Gist options
  • Save dnovais/109a2a8ed81fded492e2bc3b1b1a50b1 to your computer and use it in GitHub Desktop.
Save dnovais/109a2a8ed81fded492e2bc3b1b1a50b1 to your computer and use it in GitHub Desktop.
Print 'Hello world!' 50 times without a loop

Print 'Hello world!' 50 times without a loop

Usando recursividade

def print(times: 1, msg:)
  puts msg
  times += 1
  print(times: times, msg: msg) unless times > 50
end

print(msg: 'hello world!')

Usando lambda e recursividade

print = lambda{|times=1| puts 'hello world'; times += 1; print.
call(times) unless times > 50}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment