Skip to content

Instantly share code, notes, and snippets.

@rakhmad
Forked from airspeedswift/joke.swift
Created June 8, 2017 05:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rakhmad/686980172f4f2b87e9416b281401a17e to your computer and use it in GitHub Desktop.
Save rakhmad/686980172f4f2b87e9416b281401a17e to your computer and use it in GitHub Desktop.
Multiline Literals
func tellJoke(name: String, character: Character) {
let punchline = name.filter { $0 != character }
let n = name.count - punchline.count
let joke = """
Q: Why does \(name) have \(n) \(character)'s in their name?
A: I don't know, why does \(name) have \(n) \(character)'s in their name?
Q: Because otherwise they'd be called \(punchline).
"""
print(joke)
}
tellJoke(name: "Edward Woodward", character: "d")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment