Skip to content

Instantly share code, notes, and snippets.

fizzbuzzes = (1..100).to_a.map do |i|
if i % 15 == 0 then "fizzbuzz"
elsif i % 3 == 0 then "fizz"
elsif i % 5 == 0 then "buzz"
else i
end
end
puts fizzbuzzes
(1..100).each{|i|
x = ''
x += 'Fizz' if i%3==0
x += 'Buzz' if i%5==0
puts(x.empty? ? i : x);
}
["red","yellow","green"].each do |color|
a = color
end
puts a
rainbow = []
["red", "orange", "yellow", "green", "blue", "indigo", "violet"].each do |color|
rainbow << color
end
puts rainbow
def my_method
name_list = []
%w[Sarah Sara Kate Keturah Chris Lavoisier Armando Derek].each do |name|
name_list << name
end
end
require 'awesome_print'
ITEMS = [ {"AVOCADO" => {:price => 3.00, :clearance => true}},
{"KALE" => {:price => 3.00,:clearance => false}},
{"BLACK_BEANS" => {:price => 2.50,:clearance => false}},
{"ALMONDS" => {:price => 9.00, :clearance => false}},
{"TEMPEH" => {:price => 3.00,:clearance => true}},
{"CHEESE" => {:price => 6.50,:clearance => false}},
{"BEER" => {:price => 13.00, :clearance => false}},
{"PEANUTBUTTER" => {:price => 3.00,:clearance => true}},
class Cylon
def initialize(parts)
@CPU = parts[:cpu]
@mcp_chip = parts[:MCP]
end
def some_cylon_action
# I don't know, lifting trucks in the air or something.
end
class Cylon
def initialize(parts)
@CPU = parts[:cpu]
@mcp_chip = parts[:MCP]
@cool_new_centurion_part = parts[:cool_new_centurion_part]
end
def some_cylon_action
# I don't know, lifting trucks in the air or something.
end
class Cylon
def initialize(parts)
@CPU = parts[:cpu]
@mcp_chip = parts[:MCP]
@cool_new_centurion_part = parts[:cool_new_centurion_part]
end
def some_cylon_action
# I don't know, lifting trucks in the air or something.
end
class Cylon
def initialize(parts)
@CPU = parts[:cpu]
@mcp_chip = parts[:MCP]
end
def thing_all_cylons_can_do
# hate humans or something.
end