Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Online resources:

  • BrainPop
  • Curiosity Stream
  • Tynker
  • Outschool
  • Udemy
  • iReady
  • Beast Academy (Math)
  • Khan Academy (Offers courses based on school year)
  • Creative Bug
@Rheeseyb
Rheeseyb / Playground.swift
Created October 2, 2016 10:38
In Swift, repeatedly attempt a series of failable functions, failing if any of them fail
import Cocoa
enum Failable<T> {
case fail
case success(T)
func map<U>(fn: (T) -> U) -> Failable<U> {
switch self {
case .fail: return .fail
case let .success(t): return .success(fn(t))