Skip to content

Instantly share code, notes, and snippets.

@morishin
Created March 7, 2017 16:25
Show Gist options
  • Save morishin/4bc055923617694e3b1f3b26d4bccb9d to your computer and use it in GitHub Desktop.
Save morishin/4bc055923617694e3b1f3b26d4bccb9d to your computer and use it in GitHub Desktop.
import Foundation
import Runes
struct Recipe {
let imageURLString: String?
}
let recipe = Recipe(imageURLString: "http://hoge/image.png")
// default
if let imageURLString = recipe.imageURLString, let imageURL = URL(string: imageURLString) {
print(imageURL)
}
// with Runes
if let imageURL = recipe.imageURLString >>- { URL(string: $0) } {
print(imageURL)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment