ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
class A
end
a = A.new
A === a
internet () { | |
if ( | |
ping -c 3 -t 3 google.com > /dev/null 2>&1 | |
) | |
then | |
echo 'yep' | |
else | |
echo 'nope' | |
fi | |
} |
module ActiveRecord::Associations::Builder | |
class HasAndBelongsToMany < CollectionAssociation #:nodoc: | |
def define_destroy_hook | |
name = self.name | |
model.send(:include, Module.new { | |
class_eval <<-RUBY, __FILE__, __LINE__ + 1 | |
def destroy_associations | |
association(#{name.to_sym.inspect}).delete_all_on_destroy | |
super | |
end |
asldkjaldkj |
type Result { | |
Value T | |
Err error | |
} |
class Contract | |
@created = {} | |
@fullfilled = {} | |
def self.create argument | |
@created[argument] = caller[0] | |
end | |
def self.fulfill argument | |
@fullfilled[argument] = caller[0] |
-- in haskell, this is all abstracted away by syntactic sugar. | |
-- although the function type syntax probably looks familiar. | |
add :: Integer -> Integer -> Integer | |
add x y = x + y | |
-- can curry as well | |
inc = add 1 | |
-- haskell functions all only have one arg in reality, | |
-- further arguments are always handled this way |
N = 10_000_000 | |
class Foo | |
def initialize | |
@ary = (0..N).map { Object.new } | |
end | |
def a | |
return proc do | |
"hello" |
N = 10_000_000 | |
class Foo | |
def initialize | |
@ary = (0..N).map { Object.new } | |
end | |
def a | |
# this is a closure that has captured self | |
define_singleton_method("O_o") {} |
const c = { | |
and: a => b => a(b)(c.false), | |
exp: m => n => n(m), | |
false: a => b => b, | |
isEQ: m => n => c.and(c.isLE(m)(n))(c.isLE(n)(m)), | |
isLE: m => n => c.isZ(c.sub(m)(n)), | |
isZ: n => n(x => c.false)(c.true), | |
mult: m => n => f => m(n(f)), | |
plus: m => n => f => x => m(f)(n(f)(x)), | |
pred: n => f => x => n(g => h => h(g(f)))(u => x)(u => u), |