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
## Model code | |
class Customer < ActiveRecord::Base | |
def find_by_name(name) | |
Option[where(name: name).first] | |
end | |
end | |
## Controller code |
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
"Nils - what are your Options?" - Russell Dunphy | |
Tony Hoare, inventor of the null reference, calls it his "billion dollar mistake". | |
Although Ruby goes some way to correcting it by making `nil` at least be a class | |
with some reasonably helpful stuff on it, you'll no doubt have been hit by a | |
`NoMethodError: undefined method 'foo'` just as many times as me. | |
So, given this problem exists, I want to convince you of a few things. | |
First, that there are not one, but two types of `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
(defun restart-sml () | |
(sml-prog-proc-switch-to) | |
(end-of-buffer) | |
(comint-delchar-or-maybe-eof 0)) | |
(defun run-sml-tests-now () | |
(let* ((code-file-name | |
(replace-regexp-in-string "_tests" "" (buffer-file-name))) | |
(test-file-name | |
(replace-regexp-in-string "\.sml" "_tests.sml" code-file-name))) |
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 'rspec' | |
class Object | |
def peg(&block) | |
block.call(self) | |
end | |
def wend(arg) | |
Wender.new(self, arg) |
NewerOlder