This file contains 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
loop do | |
puts 'This is the outer loop.' | |
loop do | |
puts 'This is the inner loop.' | |
break | |
end | |
break | |
end |
This file contains 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
SUITS = %w[C H D S] | |
SUITS_HASH = { 'C' => 'Clubs', | |
'H' => 'Hearts', | |
'D' => 'Diamonds', | |
'S' => 'Spades' } | |
DEALER_STOPS_AT = 17 | |
BUST_IF_OVER = 21 | |
def prompt(msg) | |
puts "==> #{msg}" |
This file contains 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
#city_park.rb | |
class CityPark | |
attr_reader :name, :num_trees | |
def initialize(name, num_trees) | |
@name = name | |
@num_trees = num_trees | |
end | |
end |
This file contains 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
# greenspace.rb | |
class GreenSpace | |
attr_reader :name, :num_trees | |
def initialize(name, num_trees) | |
@name = name | |
@num_trees = num_trees | |
end | |
end |
This file contains 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
# recreation_centre.rb | |
module Swimmable | |
def swim | |
"Can swim here!" | |
end | |
end | |
class GreenSpace | |
attr_reader :name, :num_trees |
This file contains 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
# recreation_centre_expanded.rb | |
module Swimmable | |
def swim | |
"Can swim here!" | |
end | |
end | |
class GreenSpace | |
attr_accessor :name, :num_trees |
This file contains 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
# recreation_centre_last_example.rb | |
module Swimmable | |
def swim | |
"Can swim here!" | |
end | |
end | |
class GreenSpace | |
attr_accessor :name, :num_trees |
This file contains 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
{ | |
"PEDAC": { | |
"scope": "ruby", | |
"prefix": "PEDAC", | |
"body": [ | |
"=begin", | |
"Input: $1", | |
"Output: $2", | |
"\nProblem: \n\t- $3", | |
"\nClarifying Questions: \n\t- $4", |
This file contains 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
{ | |
"PEDAC": { | |
"scope": "javascript", | |
"prefix": "PEDAC", | |
"body": [ | |
"/*", | |
"Input: $1", | |
"Output: $2", | |
"\nProblem: \n\t- $3", |
This file contains 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
const foo = { | |
bar: 'baz', | |
getBar: function() { // assigned as a property on an object, getBar is a method | |
console.log(this.bar); // the value of this here is the direct-parent foo object context | |
}, | |
}; | |
foo.getBar() // logs 'baz' | |
const qux = foo.getBar; // assigning the function stored as the method getBar to the variable qux in the global scope |
OlderNewer