8
8

More than 5 years have passed since last update.

[Swift] ローカルスコープを実現する

Last updated at Posted at 2014-10-22

func locally を定義。

func locally(work: () -> ()) {
    work()
}

すると、locally をローカルスコープの代わりに使うことができる。

locally {
    let g = 42
    println(g)
}

参考

How to create local scopes in Swift? - Stack Overflow

8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8