Last active
February 18, 2016 14:19
-
-
Save nitaking/feda0610c8623820bb8b to your computer and use it in GitHub Desktop.
[swift]基本構文覚え書き キャストとか ref: http://qiita.com/omochiiiY/items/3f0a7b8e7f7223a1c62a
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
let x = 1 | |
var y = x + 2 * 3 / 2 | |
print("y = \(y)") // y = 4 | |
y %= 2 | |
print("y mod 2 = \(y)") // y mod 2 = 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
let x: Double = 1 | |
let y: Int = Int(x) | |
print("y = \(y)") // y = 1 |
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
let x: Double = 1 | |
let y: Int = Int(x) | |
print("y = \(y)") // y = 1 |
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
let doubleNumber: Double = 11.111 | |
let doubleStr: String = String(doubleNumber) | |
// => Error |
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
let doubleNumber: Double = 11.111 | |
let doubleStr: String = String(doubleNumber) | |
// => Error |
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
let str = "123" | |
var num = str!.toInt()//error: toInt() is unavailable |
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
let str = "123" | |
var num = str!.toInt()//error: toInt() is unavailable |
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
let str = "埋め込み" | |
print("こうやって\(str)ます。") //こうやって埋め込みます。 |
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
let x = 1 | |
var y = x + 2 * 3 / 2 | |
print("y = \(y)") // y = 4 | |
y %= 2 | |
print("y mod 2 = \(y)") // y mod 2 = 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
let intNumber: Int = 2 | |
let intStr: String = intNumber.description | |
print("intStr = \(intStr) ") // intStr = 2 |
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
let intNumber: Int = 2 | |
let intStr: String = intNumber.description | |
print("intStr = \(intStr) ") // intStr = 2 |
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
let str = "埋め込み" | |
print("こうやって\(str)ます。") //こうやって埋め込みます。 |
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
let str = "埋め込み" | |
print("こうやって(str)ます。") //こうやって(str)ます。 |
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
let str = "埋め込み" | |
print("こうやって(str)ます。") //こうやって(str)ます。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment