Skip to content

Instantly share code, notes, and snippets.

@akinov
Last active March 21, 2020 08:08
Show Gist options
  • Save akinov/985ad2ed443b9943f666bfe25a175117 to your computer and use it in GitHub Desktop.
Save akinov/985ad2ed443b9943f666bfe25a175117 to your computer and use it in GitHub Desktop.
100日後に死ぬインスタンス
require 'date'
class Crocodile
class DeadError < StandardError; end
def initialize(born = Date.today)
@born = born
end
def move
if Date.today >= @born + 100
raise DeadError
else
puts '🐊'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment