Get comfortable writing routes and creating ERB views in a very simple Sinatra App.
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
#javascript | |
for (var i=0; i<3, i++) | |
{ | |
console.log("hello"); | |
}; | |
#ruby | |
3.times do |i| | |
puts "hello" unless i == 3 | |
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
["two", "headed", "boy", 1945].each do |value| | |
puts value | |
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
[1, 2, 3, 4].each { |x| x*2 } | |
#=> [1, 2, 3, 4] | |
[1, 2, 3, 4].each { |x| print x*2 } | |
#=> 2468 => [1, 2, 3, 4] | |
[1, 2, 3, 4].collect { |x| x*2 } | |
#=> [2, 4, 6, 8] | |
[1, 2, 3, 4].each { |x| x*2 } |
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 World | |
attr_reader :world_array_y, :world_array_x | |
def initialize | |
create_world | |
@world_array_y | |
@world_array_x | |
end | |
def create_world |
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 World | |
attr_reader :board | |
def initialize | |
create_world | |
end | |
def create_world | |
@board = [] | |
30.times do |y| |
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
o . . . . . . . . . . . . o | |
. . . . . . . . . . . . . . | |
. . . . . . . . . . . . . . | |
. . . . . . . . . . . . . . | |
o . . . . . . . . . . . . o |
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
songs_i_love = { | |
"Afterlife" => "Arcade Fire", | |
"Mirrors" => "Justin Timberlake", | |
"Skinny Love" => "Bon Iver", | |
"Five Seconds" => "Twin Shadow" | |
} |
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
songs_i_love["Five Seconds"] #=> "Twin Shadows" |
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
songs_i_love.[]( "Five Seconds" ) |