Skip to content

Latest commit

 

History

History
20 lines (16 loc) · 517 Bytes

the_if_function.md

File metadata and controls

20 lines (16 loc) · 517 Bytes

Description

Create a function called _if which takes 3 arguments: a value bool and 2 functions (which do not take any parameters): func1 and func2

When bool is truthy, func1 should be called, otherwise call the func2.

Example:

_if(true, proc{puts "True"}, proc{puts "False"})
# Logs 'True' to the console.

My Solution

def _if(bool, ifTrue, ifFalse)
  bool ? ifTrue.call : ifFalse.call
end