Skip to content

Instantly share code, notes, and snippets.

@vladfaust
Created October 9, 2019 19:31
Show Gist options
  • Save vladfaust/6e709af8a906a38c45b22703cf61e6ce to your computer and use it in GitHub Desktop.
Save vladfaust/6e709af8a906a38c45b22703cf61e6ce to your computer and use it in GitHub Desktop.
Self

Self

  1. Self is contextual. There may be difficulties for understanding when need instance and when type.
def == (other : self(T)) : Bool
  self.id == other.cast(self).id
end
  1. self for type reference, this for instance reference (or vice versa). Allows more detailed highlighting (self is a type).
def == (other : self(T)) : Bool
  this.id == other.cast(self).id
end
  1. self for instance reference, Self for type reference. Allows more detailed highlighting (Self is a type).
def == (other : Self(T)) : Bool
  self.id == other.cast(Self).id
end
  1. ???
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment