forked from demostudent24/ruby-sandbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThink Fast.rb
More file actions
38 lines (37 loc) · 921 Bytes
/
Think Fast.rb
File metadata and controls
38 lines (37 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
unpredictable_inputs = [
"Hello!",
Time.now,
rand(100),
:GOODBYE,
nil,
true,
false,
{ :city => "Chicago", :state => "IL", :zip => 60654 }
]
some_random_input = unpredictable_inputs.sample
# write your program below
if some_random_input.class == String
pp some_random_input.downcase
elsif some_random_input.class == Time
pp some_random_input.strftime("%A").downcase
elsif some_random_input.class == Integer
if some_random_input.odd?
pp "#{some_random_input} is odd"
else
pp "#{some_random_input} is even"
end
elsif some_random_input.class == Symbol
pp some_random_input.downcase
elsif some_random_input.class == nil
pp "no object provided"
elsif some_random_input == true
pp "you may pass"
elsif some_random_input == false
pp "you may not pass"
elsif some_random_input.class == Hash
new_array = Array.new
some_random_input.each do |key, value|
new_array.push(key)
end
pp new_array
end