![show/hide quicksearch [+]](../images/find.png)
 
               # File rbs-1.0.4/lib/rbs/substitution.rb, line 18
def self.build(variables, types, instance_type: nil, &block)
  unless variables.size == types.size
    raise "Broken substitution: variables=#{variables}, types=#{types}"
  end
  mapping = variables.zip(types).to_h
  self.new.tap do |subst|
    mapping.each do |v, t|
      type = block_given? ? yield(t) : t
      subst.add(from: v, to: type)
    end
    subst.instance_type = instance_type
  end
end
             
             
               # File rbs-1.0.4/lib/rbs/substitution.rb, line 14
def add(from,, to))
  mapping[from] = to
end
             
             
               # File rbs-1.0.4/lib/rbs/substitution.rb, line 35
def apply(ty)
  case ty
  when Types::Variable
    # @type var ty: Types::Variable
    mapping[ty.name] || ty
  when Types::Bases::Instance
    if t = instance_type
      t
    else
      ty
    end
  else
    ty
  end
end