-
-
Save indigoviolet/4b315aee733e1753a2fb35f21b8bfa76 to your computer and use it in GitHub Desktop.
fin blog embed
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 ImmutabilityError < StandardError; end | |
Contract Hash => DescendantOf[KeywordStruct] | |
def self.define(**args) | |
KeywordStruct.new(*args.keys) do | |
include C | |
Contract KeywordArgs[**args] => Any | |
def initialize(**params) | |
super | |
end | |
args.keys.each do |k| | |
define_method "#{k}=" do |_val| | |
raise ImmutabilityError.new | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment