==(other)
click to toggle source
def ==(other)
other.is_a?(Optional) && other.type == type
end
each_type()
click to toggle source
def each_type
if block_given?
yield type
else
enum_for :each_type
end
end
eql?(other)
click to toggle source
free_variables(set = Set.new)
click to toggle source
def free_variables(set = Set.new)
type.free_variables(set)
end
hash()
click to toggle source
def hash
self.class.hash ^ type.hash
end
map_type_name(&block)
click to toggle source
def map_type_name(&block)
Optional.new(
type: type.map_type_name(&block),
location: location
)
end
sub(s)
click to toggle source
def sub(s)
self.class.new(type: type.sub(s), location: location)
end
to_json(*a)
click to toggle source
def to_json(*a)
{ class: :optional, type: type, location: location }.to_json(*a)
end
to_s(level = 0)
click to toggle source
def to_s(level = 0)
case t = type
when RBS::Types::Literal
case t.literal
when Symbol
return "#{type.to_s(1)} ?"
end
end
"#{type.to_s(1)}?"
end