Skip to content

Instantly share code, notes, and snippets.

View bugaevc's full-sized avatar

Sergey Bugaev bugaevc

View GitHub Profile
@JadenGeller
JadenGeller / Cluster.swift
Created March 13, 2017 01:27
Class Cluster
class Number /* class cluser */ {
class Int8: Number {
var value: Swift.Int8
init(_ value: Swift.Int8) { self.value = value }
}
class Int: Number {
var value: Swift.Int
init(_ value: Swift.Int) { self.value = value }
}
@algal
algal / SelfAssigningReferenceTypes.swift
Last active October 26, 2017 09:01
Brief exploration of Swift classes that assign to self via protocol extensions
/*
## background
When you write a function that mutates the var properties of a
mutable struct, this _creates a new instance_.[1] As a result,
a variable pointing to a value of this type before the mutation
will still be pointing to the old value after the mutation, as long
as you did not use that variable to do the mutation.