본문 바로가기

전체 글170

Swift Enumerations - Enumerationsenumeration은 enum 키워드로 만들 수 있다. enumeration은 Class와 같은 다른 형식들과 마찬가지로자기자신과 관련된 Method를 가질 수 있다. enum Rank: Int { case Ace = 1 case Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten case Jack, Queen, King func simpleDescription() -> String { switch self { case .Ace: return "ace" case .Jack: return "jack" case .Queen: return "queen" case .King: return "king" default: return String(.. 2014. 6. 29.
Swift Objects and Classes #3 -Class에서의 Method는 함수와는 다른 중요한 차이가 하나 있다. 함수에서 인자는 함수 내에서만사용되지만 Class의 Method는 첫번째 인자를 제외하고는 Method를 호출할 때에도 별도의 이름을지정해 사용될 수 있다. Method안에서 사용되어지는 두번째 인자명을 지정할 수도 있다. class Counter { var count: Int = 0 func incrementBy(amount: Int, numberOfTimes times: Int) { count += amount * times }}var counter = Counter()counter.incrementBy(2, numberOfTimes: 7) - optional values을 사용할 때에는 methods, properties, a.. 2014. 6. 29.
Hadoop OutputCollector - OutputCollector OutputCollector 는 Mapper 또는 Reducer 에 의해 처리된 데이터를 출력하기 위한 인터페이스 이다. 예를 들어 output.collect(key, value) 는 Map 수행결과를 출력하게 된다. 2014. 6. 27.
Swift Objects and Classes #2 - Properties getter setter - Properties properties는 getter와 setter를 가진다. class NamedShape { var numberOfSides: Int = 0 var name: String init(name: String) { self.name = name } func simpleDescription() -> String { return "A shape with \(numberOfSides) sides." }} class EquilateralTriangle: NamedShape { var sideLength: Double = 0.0 init(sideLength: Double, name: String) { self.sideLength = sideLength super.init(name: name) n.. 2014. 6. 24.