Skip to content

Instantly share code, notes, and snippets.

@alexaltair
alexaltair / gem_update.md
Last active December 24, 2015 11:39
Steps to take when updating or creating a gem.
@alexaltair
alexaltair / unknown.md
Created July 29, 2013 16:16
Things I don't recognize
@alexaltair
alexaltair / ruby_practice.rb
Created July 8, 2013 04:43
Weekend Ruby practice
def fibonacci(n)
if (0..1) === n
n
else
fibonacci(n-1) + fibonacci(n-2)
end
end
def prime_list(highest)
list = Array.new(highest, true)
@alexaltair
alexaltair / attr_accessor.md
Last active December 18, 2015 21:59
Quick explanation of attribute accessors.

In class definitions,

attr_accessor :name, :email, :phone_number

is the same as

attr_reader :name, :email, :phone_number
@alexaltair
alexaltair / Today's Learning.md
Last active December 18, 2015 17:38
An exploration of infinite lists.

The first thing that really surprised me today was the flexibility of Ruby's shovel operator, <<. A student in the class had tried the following:

a = [0]
a << a

What do you think a is now? I was sure it would be [0, [0]]. But lo and behold, Ruby sparkles;

a = [0]
a &lt;&lt; a