Slide 32
Slide 32 text
1 class IsString
2 def string?(value : String) : String
3 "hey, #{value} is string :)"
4 end
5
6 def string?(value : Number) : String
7 "man, #{value} is a number :|"
8 end
9
10 def string?(value : String, _other) : String
11 "One of them"
12 end
13
14 def string?(_other, value : String)
15 string?(value, nil)
16 end
17
18 def string?(_value) : String
19 "I don't care"
20 end
21 end
22
23 is = IsString.new
24 puts is.string?("ok", 0) # One of them
25 puts is.string?(0, "ok") # One of them
32 / 43