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
// すべてがtrueか? | |
boolean flag = true; | |
for (boolean bit : bits) flag &= bit; | |
// 1つでもtrueか? | |
boolean flag = false; | |
for (boolean bit : bits) flag |= bit; |
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
if ([someString length] > 0) { // 0が偽なのでnilチェックは不要 | |
} |
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
#define IS_EMPTY(s) ((s == nil) || ([s length] == 0)) | |
NSString *emptyString = @""; | |
NSString *nilString = nil; | |
NSString *someString = @"foo"; | |
// nilまたは空文字列でないかチェックする | |
NSLog(@"%@", !IS_EMPTY(emptyString) ? @"YES" : @"NO"); | |
NSLog(@"%@", !IS_EMPTY(nilString) ? @"YES" : @"NO"); | |
NSLog(@"%@", !IS_EMPTY(someString) ? @"YES" : @"NO"); |
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 "NSString+Additions.h" | |
@implementation NSString (Additions) | |
- (BOOL)isNotEmpty { | |
return [self length] > 0; | |
} | |
@end |
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 old = 17 | |
let foo = "I am \(old) old years." |
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 java.util.stream.Stream; | |
public class FizzBuzzSample { | |
public static void main(String[] args) { | |
// Stream.iterateを使用して自然数(の無限数列)のストリームを用意 | |
Stream<Integer> naturalNumbers = Stream.iterate(1, integer -> integer + 1); | |
// 自然数(の無限数列)をfizzBuzzメソッド(参照)を利用して文字列のストリームに変換 |
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 | |
extension Array { | |
func forEach(f: T -> ()) { | |
for n:T in self { | |
f(n) | |
} | |
} | |
} |
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 p = Person(name: "Yusuke Hosonuma") | |
Mirror(reflecting: p).children.forEach { | |
print("\($0.label!), \($0.value)") | |
} |
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
// | |
// ViewController.swift | |
// APISample | |
// | |
// Created by Yusuke on 11/8/15. | |
// Copyright © 2015 Yusuke. All rights reserved. | |
// | |
import UIKit |
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
// | |
// SampleAPI.swift | |
// APISample | |
// | |
// Created by Yusuke on 11/8/15. | |
// Copyright © 2015 Yusuke. All rights reserved. | |
// | |
import Foundation |
OlderNewer