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
func fizzBuzz(num: Int) -> String { | |
switch num { | |
case _ where num % 15 == 0: | |
return "FizzBuzz" | |
case _ where num % 3 == 0: | |
return "Fizz" | |
case _ where num % 5 == 0: | |
return "Buzz" | |
default: | |
return num.description |
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
#import "UserDefaultsUtility.h" | |
@implementation UserDefaultsUtility | |
/** | |
ユーザデフォルトに設定したオブジェクトを取得する | |
*/ | |
+ (id) objectForKey:(NSString*) key { | |
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; | |
NSData *encodedObject = [userDefaults objectForKey:key]; |
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
import UIKit | |
for fn in UIFont.familyNames { | |
for font in UIFont.fontNames(forFamilyName: fn) { | |
print("font: \(font)") | |
} | |
} |
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
#lang racket | |
(/ (+ 5 4 | |
(- 2 | |
(- 3 | |
(+ 6 | |
(/ 4 5))))) | |
(* 3 | |
(- 6 2) | |
(- 2 7))) |
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 path = Bundle.main.path(forResource: "foo", ofType: "json") | |
let data: NSData? = try? NSData(contentsOfFile: path!, options: .uncached) |
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
#lang racket | |
(define (sum_of_square a b c) | |
(cond ((< a b) (< a c) (+ (* b b) (* c c))) | |
((< b c) (< b a) (+ (* a a) (* c c))) | |
(else (+ (* a a) (* b b))) | |
) | |
) | |
(sum_of_square 3 4 5) ;41 | |
(sum_of_square 8 4 5) ;89 |
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
import Foundation | |
import PromiseKit | |
struct YoRepository { | |
func fetchDataWithPromise() -> Promise<String> { | |
return Promise { seal in | |
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + .milliseconds(500)) { | |
guard true else { | |
// failure | |
seal.reject(MyError.unknown) |
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
#lang racket | |
(define (average x y) | |
(/ (+ x y) 2)) | |
(define (improve guess x) | |
(average guess (/ x guess))) | |
(define (sqrt-iter guess x) | |
(if (good-enough? guess x) | |
guess |
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
import Foundation | |
// https://developer.apple.com/documentation/foundation/nscomparisonresult | |
let currentVersion = "0.0.2" | |
let latestVersion1 = "0.0.3" | |
let latestVersion2 = "0.0.21" | |
let latestVersion3 = "0.1.0" | |
let latestVersion4 = "1.0.0" | |
let latestVersion5 = "0.0.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
OVERVIEW: Swift compiler | |
USAGE: swiftc [options] <inputs> | |
MODES: | |
-dump-ast Parse and type-check input file(s) and dump AST(s) | |
-dump-parse Parse input file(s) and dump AST(s) | |
-dump-scope-maps <expanded-or-list-of-line:column> | |
Parse and type-check input file(s) and dump the scope map(s) | |
-dump-type-refinement-contexts |
OlderNewer