I hereby claim:
- I am jmont on github.
- I am jmont (https://keybase.io/jmont) on keybase.
- I have a public key whose fingerprint is 9416 F219 A1B6 A6E5 0AA8 B371 793F 0B31 DB85 519F
To claim this, I am signing this object:
// The spread function! | |
Promise.resolve([thing1, thing2, thing3]).spread((thing1, thing2, thing3) => { /* Do something! */ }) | |
// Upserting a sample Movie model | |
import Models from 'db/models/index' | |
updateMovie (movie, params) { | |
return this.updateMovieWParams(movie, params).spread(this.upsertTagsForMovie).spread(this.updateMovieInfo).spread((movie, params) => movie) |
// The spread function! | |
Promise.resolve([thing1, thing2, thing3]).spread((thing1, thing2, thing3) => { /* Do something! */ }) | |
// Upserting a sample Movie model | |
import Models from 'db/models/index' | |
updateMovie (movie, params) { | |
return this.updateMovieObject(movie, params).spread(this.upsertTagsForMovie).spread(this.updateMovieInfo).spread((movie, params) => movie) |
I hereby claim:
To claim this, I am signing this object:
operator infix -%- { associativity left } | |
func -%-<TypeA, TypeB, TypeC> (f: TypeB -> TypeC, g: TypeA -> TypeB) -> (TypeA -> TypeC) { | |
return ({ x in f(g(x)) }) | |
} | |
func add3(x:Int) -> Int { | |
return x + 3; | |
} | |
func add7(x: Int) -> Int { |
// Curried Functions in Swift | |
// Juan C. Montemayor (@norsemelon) | |
// Excerpt From: Apple Inc. “The Swift Programming Language.” iBooks. https://itun.es/us/jEUH0.l | |
// Syntax: func name (x1: t1)(x2: t2) -> t { ... } | |
// Note: it has a paren pair for every variable, as opposed to `(x1: t1, x2: t2)` | |
func addTwoNumbers(a: Int)(b: Int) -> Int { | |
return a + b | |
} | |
// Swift Monads -- Maybe | |
// Juan C. Montemayor (@norsemelon) | |
// This operator can be used to chain Optional types like so: | |
// optionalVal >>= f1 >>= f2 | |
// where f1 and f2 have type `Any -> Any?` | |
// | |
// If a value is ever nil, the chain short-circuits and will result in nil. | |
// This is a much neater way to do this than using the if syntax specified in | |
// the Swift iBook. |
- (id)xxx_decoder:(NSCoder *)decoder decodeObjectOfClass:(Class)class forKey:(id)key { | |
id obj = [decoder decodeObjectForKey:key]; | |
if (![obj isKindOfClass:class]) { | |
return nil; | |
} | |
return obj; | |
} |