fn main() {
let x = "hi"; // lifetime a.
let e; // e should have a lifetime a.
{
let y = "you"; // lifetime b.
e = check(&x, &y); // here we returned lifetime b.
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
import PlaygroundSupport | |
public func playgroundShouldContinueIndefinitely() { | |
PlaygroundPage.current.needsInfiniteExecution = true | |
} |
Testing JavaScript isn't just a thing you can read about in children's fairy tales.
This is just a scratch pad of everything I find. As the really good resources start to float to the top, I'll transition them to a more permanent GitHub repo.
- Test-Driven JavaScript Development [book]
- JavaScript Testing Recipes [book]
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
#ack is a tool like grep, designed for programmers with large trees of heterogeneous source code | |
#to install ack, see http://betterthangrep.com/ | |
#to use ack, launch terminal (mac osx) and type 'ack <some_keywords>' | |
#ack will search all files in the current directory & sub-directories | |
#here's how I have my config file setup. this file is located on mac osx here | |
# ~/.ackrc | |
# Always sort the files |
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
require_relative "customer" | |
require_relative "user" | |
# context bind role to object. | |
# by using the extend method in ruby. | |
# now the data object has some behaviors that get from the role class(Customer). | |
class Context | |
def initialize(user, book) | |
@customer, @book = user, book | |
@customer.extend(Customer) |
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
//: Playground - noun: a place where people can play | |
import AppKit | |
let dateFormatter = DateFormatter() | |
dateFormatter.dateStyle = .long | |
dateFormatter.timeStyle = .none | |
let dateStr = "2017-10-12" |
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 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
mr Marathi | |
bs Bosnian | |
ee_TG Ewe (Togo) | |
ms Malay | |
kam_KE Kamba (Kenya) | |
mt Maltese | |
ha Hausa | |
es_HN Spanish (Honduras) | |
ml_IN Malayalam (India) | |
ro_MD Romanian (Moldova) |
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
// | |
// https://medium.com/@jegnux/safe-collection-subsripting-in-swift-3771f16f883 | |
// https://github.com/ReactiveX/RxSwift/issues/826 | |
// | |
import Foundation | |
// we define a fire protocol. | |
protocol FireProtocol { |
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
// So associated objects just store object in anoter place, use property to | |
// associate the object with the class object. | |
import Foundation | |
let data: Data? | |
var dataKey: Void? | |
data = Data(count: 10) | |
data?.insert(9, at: 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
/// https://github.com/apple/swift-evolution/blob/master/proposals/0142-associated-types-constraints.md | |
protocol SubContainer: Container { | |
associatedtype Item: Equatable | |
} | |
protocol Container { | |
associatedtype Item | |
// error: 'where' clause cannot be attached to an associated type declaration | |
// error: type may not reference itself as a requirement |