Created
September 23, 2021 06:46
-
-
Save seban/03ab9a616be5567bcc23cb4c7da66e02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CaseTest | |
def initialize(number) | |
@number = number | |
end | |
def test | |
case @number | |
when it_is_eight? | |
'eight' | |
when it_is_five? | |
'five' | |
else | |
'whatever' | |
end | |
end | |
private | |
def it_is_eight? | |
->(n) { n == 8 } | |
end | |
def it_is_five? | |
->(n) { n == 5 } | |
end | |
end | |
puts CaseTest.new(5).test | |
puts CaseTest.new(8).test | |
puts CaseTest.new(15).test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment