- Option: "None is a totally valid result, usually found in data structures"
- unwrap(): YOLO use in prototyping
- expect(...): to indicate the reason you believe None is impossible (or a contract violation for the method)
- Result: 😱 "Errors are unexpected but not bugs; the decision for how to handle them is up to the caller"
- unwrap(): YOLO "I'm an app and don't know how to handle this error -- I'm fine if the whole process aborts"
- try! / ?: "Leave the decision about how to handle this error to the caller; they have more information"
- match / catch: "I'm going to handle the error right here right now"
- panic!: ☠ "The error is a bug and can't be recovered from. Game over man. Rust is allowed to abort the process if it wants"
This file contains 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
poem = | |
"My honeydew has flown from my hand | |
And my toast has gone to the | |
moon. | |
But when I saw it on television, | |
Planting our flag on Halley's | |
comet, | |
More still did I want to eat it. | |
" |
This file contains 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() some stuff from npm (like you were using browserify) | |
// and then hit Run Code to run it on the right | |
var fs = require("fs"); |
This file contains 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
bash-4.3# ./dev-environment.sh | |
tune2fs 1.42.13 (17-May-2015) | |
Setting maximal mount count to -1 | |
Setting interval between checks to 0 seconds | |
Creating journal inode: done | |
which: no distccd in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin) | |
distccd pid 25684 port 9256 | |
WARNING: Image format was not specified for 'toolchain.sqf' and probing guessed raw. | |
Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. | |
Specify the 'raw' format explicitly to remove the restrictions. |
This file contains 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 Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName:'Ember Twiddle' | |
}); |
This file contains 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
module Mst | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
def before(method_name) | |
m = instance_method(method_name) | |
define_method method_name do |*args, &block| |
This file contains 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 Person { | |
@reader _first, _last; | |
constructor(first, last) { | |
this._first = first; | |
this._last = last; | |
} | |
} | |
class Person { |
This file contains 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
export default Ember.Controller.extend({ | |
appName:'Ember Twiddle' | |
}); |
This file contains 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
export default function ifHelper([value]) { | |
if (value) { | |
this.yield(); | |
} | |
} |
This file contains 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 Parent extends Person { | |
constructor() { | |
super(arg1, arg2); | |
// desugars to | |
// InitializeThis(<activefunction>.__proto__.[[Construct]]([arg1, arg2], NewTarget); | |
} | |
someMethod() { | |
// these are equivalent |