Here is the code that meets the requirements you mentioned:
main.rb271 chars15 lines
In this code, we define a function check_number
that takes an argument n
. Inside the function, we create an array [1, 2, 3]
and check if n
is included in the array using the include?
method. If n
is in the array, we execute the code block inside the if
statement (replace # do sth
with your desired actions). Otherwise, we execute the code block inside the else
statement (replace # do sth else
with your desired actions).
Hope this helps!
gistlibby LogSnag