Skip to content

Instantly share code, notes, and snippets.

@jonahgeorge
Created July 18, 2016 23:23
Show Gist options
  • Save jonahgeorge/a56032c3f35ce328aa446d24994e7353 to your computer and use it in GitHub Desktop.
Save jonahgeorge/a56032c3f35ce328aa446d24994e7353 to your computer and use it in GitHub Desktop.
class Connection
class Connected
def disconnect
Disconnected.new
end
end
class Disconnected
def connect
Connected.new
end
end
def self.new
Disconnected.new
end
end
x = Connection.new
# x.disconnect # compile-time error
x = x.connect
# x.connect # compile-time error
x = x.disconnect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment