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
================== | |
WARNING: DATA RACE | |
Read at 0x00c0001ed200 by goroutine 114: | |
code.cloudfoundry.org/gorouter/route.(*Pool).IsOverloaded() | |
/Users/pivotal/workspace/routing-release/src/code.cloudfoundry.org/gorouter/route/pool.go:337 +0x1aa | |
code.cloudfoundry.org/gorouter/handlers.(*lookupHandler).ServeHTTP() | |
/Users/pivotal/workspace/routing-release/src/code.cloudfoundry.org/gorouter/handlers/lookup.go:45 +0xda | |
github.com/urfave/negroni.middleware.ServeHTTP() | |
/Users/pivotal/workspace/routing-release/src/github.com/urfave/negroni/negroni.go:33 +0x116 | |
github.com/urfave/negroni.middleware.ServeHTTP-fm() |
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
# This is how you define your own custom exception classes | |
require 'debugger' | |
class NoOrangesError < StandardError | |
end | |
class OrangeTree | |
# Ages the tree one year | |
attr_accessor :dead, :oranges, :age, :height |
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
# Solution for Challenge: Ruby Drill: Exploring Scope. Started 2013-07-22T18:55:03+00:00 | |
THIS_IS_A_CONSTANT = "constantS" | |
$global_var = "This is my global variable. Don't Do THIS!!!" | |
def get_constant | |
THIS_IS_A_CONSTANT | |
end |
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
# Solution for Challenge: Ruby Drill: The self Keyword. Started 2013-07-22T18:43:38+00:00 | |
# There are two representations of self that one can use at any time: | |
# 1. When defining a class method, self refers to the current class | |
# 2. When using an instance of a class, self refers to the current instance | |
# Self refers to the object you are currently calling a method on |
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
def problems(number) | |
case number | |
when number > 99 | |
puts "have a lot of problems" | |
else | |
puts "have none" | |
end | |
end | |
problems(100) |
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
class Dictionary | |
attr_reader :entries | |
def initialize | |
@entries = Hash.new | |
end | |
def add(add_text) | |
if add_text.class == Hash | |
add_text.each do |key, value| |
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
class Book | |
attr_reader :title | |
def title=(title) | |
@title = "" | |
@dont_capitalize = %w(and or the an of in a) | |
words = title.split | |
words.each_with_index do |word, index| | |
if @dont_capitalize.include?(word) && index != 0 | |
@title += "#{word} " |
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
def translate(phrase) | |
parts = phrase.split | |
final_pigs = [] | |
parts.each do |word| | |
char = word.split(//) | |
unless char.at(0).match(/[aeiou]/) | |
new_string = char |
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
class LotteryTicket | |
NUMERIC_RANGE = 1..25 | |
attr_reader :picks, :purchased | |
def initialize(*picks) | |
if picks.length != 3 | |
raise ArgumentError, "You must pick three numbers" | |
elsif picks.uniq.length != 3 | |
raise ArgumentError, "You must pick three unique numbers" |
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
my_array_hash = [{"foo" => "bar"}, {"bagel" => "chips"}] | |
my_array_hash.shift["foo"] | |
returns bar |