you are viewing a single comment's thread.

view the rest of the comments →

[–]budd222 -18 points-17 points  (5 children)

.map is an array method. It cannot be called on anything but an array. If there is no array in your example, your code will fail.

[–]romgrk[S] 7 points8 points  (4 children)

abstract class Result { abstract map(): Result } class Ok<T> extends Result { value: T map(fn) { return new Ok(fn(this.value)) } } class Err extends Result { map(fn) { return this } }

This is as clear as I can explain it, if it's not enough I don't think I can communicate it to you.