Skip to content

Instantly share code, notes, and snippets.

@carlows
Created January 10, 2019 17:06
Show Gist options
  • Save carlows/7e84dfe3cc97f6cb1c9e6dfcd9219969 to your computer and use it in GitHub Desktop.
Save carlows/7e84dfe3cc97f6cb1c9e6dfcd9219969 to your computer and use it in GitHub Desktop.
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