Created
June 3, 2014 04:25
-
-
Save yfuruyama/c5031097b397a05107af to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Playground - noun: a place where people can play | |
import Cocoa | |
var str = "Hello, playground" | |
println(str) | |
var foo = 1 | |
var bar = 2 | |
var baz = foo + bar | |
for i in 1...10 { | |
i + 1 | |
} | |
func f() -> Int { | |
return 10 | |
} | |
var g = f | |
g() | |
func f2(a: Int) -> Int -> Int { | |
func internal(b: Int) -> Int { | |
return a * b | |
} | |
return internal | |
} | |
var g2 = f2(10) | |
g2(100) | |
let c = 10 | |
func makeCounter() -> () -> Int { | |
var c = 0 | |
func counter () -> Int { | |
return c++ | |
} | |
return counter | |
} | |
let counter = makeCounter() | |
let counter2 = makeCounter() | |
counter() | |
counter() | |
counter() | |
counter2() | |
counter2() | |
counter2() | |
var name = "furuyama" | |
var greeting = "Hello \(name)" | |
let oneMillion = 1_000_000 | |
var num = [1,2,3,4,5] | |
var num2 = num.map({ (n: Int) -> Int in | |
return n * 2 | |
}) | |
var num3 = num.map({ n -> Int in | |
return n * 2 | |
}) | |
func f3 (a: Int = 10) -> Int { | |
return a * 2 | |
} | |
f3() | |
f3(a: 100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment