開発環境
- OS X Mavericks - Apple(OS)
- Xcode 6.0 Beta
- Swift (プログラミング言語)
Head First JavaScript Programming (Eric T. Freeman (著)、 Elisabeth Robson (著)、 O'Reilly Media )のChapter 7(Types, Equality, Conversion and All That Jazz: Serious types))、WHO AM I?(p.267)をSwiftで考えてみる。
WHO AM I?(p.267)
コード(Xcode)
main.swift
// // main.swift // sample267 // // Created by kamimura on 8/21/14. // Copyright (c) 2014 kamimura. All rights reserved. // import Foundation func f() {} var a:AnyObject var b:AnyObject? let c = [1,2] var d = [1,2] let e = ["a":1, "b":2] var g = ["a":1, "b":2] println(f()) // println(a) println(b) // println(c[2]) out of range // println(d[2]) out of range // d[100] = 10 out of range println(e["c"]) println(g["c"]) // g["c"] g["c"] = 3 println(g)
入出力結果(Console Output)
nil nil nil [c: 3, a: 1, b: 2] Program ended with exit code: 0
0 コメント:
コメントを投稿