Created
January 10, 2019 17:06
-
-
Save carlows/7e84dfe3cc97f6cb1c9e6dfcd9219969 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 OddPunisher | |
def initialize(numbers) | |
@numbers = numbers | |
clean | |
end | |
def clean | |
@numbers.delete_if { |n| n.to_i.even? } | |
end | |
end | |
irb> numbers = [1, 2, 3, 4] | |
=> [1, 2, 3, 4] | |
irb> OddPunisher.new(numbers) | |
=> #<OddPunisher:0x007fe9eb1ae190 @numbers=[1, 3]> | |
irb> numbers | |
=> [1, 3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment