Skip to content

Instantly share code, notes, and snippets.

package memoize
import (
"fmt"
"reflect"
)
// fptr is a pointer to a function variable which will receive a
// memoized wrapper around function impl. Impl must have 1 or more
// arguments, all of which must be usable as map keys; and it must
@DanielHeath
DanielHeath / when.rb
Created December 5, 2011 22:57 — forked from avdi/when.rb
Experimenting with Object#when in Ruby
def maybe_a_sandwich
nil
end
# Methods that might return nil are annoying. We want to write a nice
# confident chain:
result = nil
result = maybe_a_sandwich.add_horseradish.get_into_my_belly! rescue $!
result # => #<NoMethodError: undefined method `add_horseradish' for nil:NilClass>
= Ruby Packaging Standard
The aim of this document is two-fold. First, to specify a common
structure of how a Ruby package distributed as source (that is, but
not limited to, development directories, version-controlled
repositories, .tar.gz, Gems, ...) should conform to.
Second, to document common and proven ways to structure Ruby packages,
and to point out certain anti-patterns that sneaked into common use.
It is by intent not to innovate.