Skip to content

Instantly share code, notes, and snippets.

@josephlord
Forked from neonichu/class-vars.swift
Last active August 29, 2015 14:13

Revisions

  1. josephlord revised this gist Jan 19, 2015. 1 changed file with 10 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion class-vars.swift
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,14 @@
    private var privateGlobalFoo = 42

    class Foo {
    class var foo: Int { return 42 }
    class var foo: Int {
    get { return privateGlobalFoo }
    set(newVal) { privateGlobalFoo = newVal }
    }
    }

    println(Foo.foo)

    Foo.foo = 114

    println(Foo.foo)
  2. @neonichu neonichu created this gist Jan 19, 2015.
    5 changes: 5 additions & 0 deletions class-vars.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    class Foo {
    class var foo: Int { return 42 }
    }

    println(Foo.foo)