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
Realm().write { | |
Realm().deleteAll() | |
} | |
let turtle = Animal() | |
turtle.name = "Turtle" | |
turtle.legCount = 4 | |
Realm().write { | |
Realm().add(turtle) |
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
if case let .OSX(version) = platform { | |
print(version) | |
} | |
if case let value? = optionalValue { | |
} | |
if case let (a?, b?, c?) = (optionalA, optionalB, optionalC) { | |
// optionalA,B,Cすべてがoptionalじゃないときだけ実行される | |
print(\(a)\(b)\(c)) |
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
// エラーハンドリング専用構文 | |
do { | |
// エラーが発生する可能性があるコード | |
} catch { | |
// エラー発生時の処理 | |
} | |
// 例 | |
do { |
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
repeat { | |
// ここを実行後にexpressionを評価 | |
} while expression | |
// 例 | |
var count = 100 | |
repeat { | |
--count | |
} while count > 0 |
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
var handle:Handle = File.open(path) | |
// defer はスコープを抜ける直前に"必ず"実行される | |
defer { | |
print("close") | |
handle.close() | |
} | |
// 複数deferすることもできる | |
defer { |
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
guard let value != 0 else { | |
// ここでスコープを抜ける処理 | |
return | |
break | |
continue | |
fatalError() | |
} | |
// 上の条件が満たされていることを前提としたコードが書ける | |
print( 100 / value ) |
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
print("hello world") |
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
2015-07-16 14:44:42.806 AlcatrazTour[71604:2586803] *** Terminating app due to uncaught exception 'RLMException', reason: 'Index is out of bounds.' | |
*** First throw call stack: | |
( | |
0 CoreFoundation 0x000000010e81bc65 __exceptionPreprocess + 165 | |
1 libobjc.A.dylib 0x0000000110386bb7 objc_exception_throw + 45 | |
2 Realm 0x000000010df7c5e7 -[RLMResults objectAtIndex:] + 343 | |
3 Realm 0x000000010df7e5ae -[RLMResults objectAtIndexedSubscript:] + 62 | |
4 AlcatrazTour 0x000000010dbc6c2c _TFC12AlcatrazTour25PluginTableViewController9tableViewfS0_FTCSo11UITableView21cellForRowAtIndexPathCSo11NSIndexPath_CSo15UITableViewCell + 140 | |
5 AlcatrazTour 0x000000010dbc6f1f _TToFC12AlcatrazTour25PluginTableViewController9tableViewfS0_FTCSo11UITableView21cellForRowAtIndexPathCSo11NSIndexPath_CSo15UITableViewCell + 79 | |
6 UIKit 0x000000010f1bb9e8 -[U |
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
PS1='\W🍣 \$' |
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
alias gemgen='rbenv local 2.1.2 && bundle init' | |
alias geminstall='bundle install --path=vendor/bundle --binstubs=vendor/bin' |