This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Given a range as input, reports fizz, buzz or fizzbuz. | |
# | |
# FizzBuzz logic is separated from presentation logic which is a concern for the reporter. | |
# | |
class FizzBuzz | |
def generate(range, reporter) | |
range.each do |n| | |
if n % 3 == 0 && n % 5 == 0 | |
reporter.report(:fizzbuzz) | |
elsif n % 3 == 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WWDC Keynote 2018 Notes | |
Introduction | |
* App Store 10 years old this year | |
* Big push into the education space | |
* Everyone should learn to code | |
* All about software today (no hardware?) | |
iOS 12 | |
* Lots of stuff about how quickly iOS is adopted |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Signal: String { | |
case dot = "." | |
case dash = "-" | |
case unknown = "?" | |
static func parseSignals(from string: String) -> [Signal] { | |
return string.flatMap() { char in | |
return Signal(rawValue: String(char)) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// becomes... | |
NotificationCenter.default.addObserver(forName: .SomethingDidHappen, ...) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
master | |
| | |
|----feature1 | |
| | | |
| |----task1 | |
| | | |
| |----task2 | |
| | |
|----feature2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol SomeProtocol { | |
typealias SomeType = String | |
} | |
class SomeClass: SomeProtocol { | |
let something: SomeType | |
} | |
// Compiles in Swift 3.1 | |
// Compile error in Swift 3.0.2: "Use of undeclared type SomeType" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def interpolate(value) | |
map { |el| [el, value] }.flatten | |
end | |
end | |
[1, 3, 5, 6].interpolate(9) #=> [1, 9, 3, 9, 5, 9, 6, 9] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let collection: Array<Int> = [1, 2, 3] | |
let optionalCollection: Array<Int>? = .None | |
expect(optionalCollection).to(equal(collection)) # fail: expected [1,2,3], got <nil> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Result<T, ErrorType> { | |
case success(T) | |
case error(ErrorType) | |
} | |
enum MyError: ErrorType { | |
case itFuckedUp | |
} | |
// no longer need unused parameters in completion blocks: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User | |
def roles | |
[:manager, :staff] | |
end | |
def has_role?(role) | |
roles.include?(role) | |
end | |
end |