Last active
December 5, 2015 14:50
-
-
Save ezura/68e3370a6df1502ba2db to your computer and use it in GitHub Desktop.
jiyugaoka:Swift? #0 でいろいろ試してみたコードたち
This file contains 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
/* | |
* 下記サイトの問題を題材にさせていただきました | |
* is AnyObject?: http://qiita.com/taketo1024/items/21d8c5fb81ab388ccdb6 | |
*/ | |
import Foundation | |
() is AnyObject | |
1 is AnyObject | |
(1, 2) is AnyObject | |
(() as ()? ) is AnyObject | |
((nil) as (NSNull)?) is AnyObject | |
(("1", "2") as (NSString, NSString)?) is AnyObject | |
var c = nil as NSNull? | |
NSNull() is AnyObject | |
let n:Int32 = 1 | |
n as NSNumber | |
protocol Sample { | |
} | |
extension Int: Sample { | |
} | |
(1 as Int) is AnyObject | |
(1 as Int?) is AnyObject | |
(1 as Int????????) is Sample? | |
let a = c ?? 0 | |
a!.dynamicType | |
//let b = c { } | |
let v1:Int? = nil | |
let v2:Int? = 2 | |
switch (v1, v2) { | |
case (let a?, let b?): | |
print(a, b) | |
case (nil, let b?): | |
print(b) | |
case (nil, nil): | |
print("nil") | |
default: | |
break | |
} | |
import Swift | |
Swift.String | |
enum Element { | |
case Dictionary([Swift.String: Element]) | |
// case Array(Element) | |
case String(Swift.String) | |
case `case`(Int) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment