Created
May 14, 2015 00:43
-
-
Save al-the-x/14276f6bf54bb53ba835 to your computer and use it in GitHub Desktop.
Ruby on Rails crash course for @TheIronYard--Orlando courtesy of @bgates
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
$> todos = "Learn Ruby" | |
=> "Learn Ruby" | |
$> todos << " on Rails" | |
=> "Learn Ruby on Rails" | |
$> todos << ", go home happy" | |
=> "Learn Ruby on Rails, go home happy" | |
$> todos.split | |
=> ["Learn", "Ruby", "on", "Rails", "go", "home", "happy"] | |
$> todos.split ',' | |
=> ["Learn Ruby on Rails", " go home happy"] | |
$> todos.split(',').each do |todo| | |
... todo.strip!.upcase << "!!!" | |
... end | |
=> ["LEARN RUBY ON RAILS!!!", "GO HOME HAPPY!!!"] | |
$> todos | |
=> "Learn Ruby on Rails, go home happy" | |
$> todos = todos.split ', ' | |
=> ["Learn Ruby on Rails", "go home happy"] | |
$> todos.map do |todo| | |
... { :text => todo, :done => false } | |
... end | |
=> [{:text=>"Learn Ruby on Rails", :done=>false}, {:text=>"go home happy", :done=>false}] | |
$> todos = todos.map do |todo| | |
... { :text => todo, :done => false } | |
... end | |
$> todos << {:text => "go to bed", :done => false} | |
=> [{:text=>"Learn Ruby on Rails", :done=>false}, {:text=>"go home happy", :done=>false}, {:text=>"go to bed", :done=>false}] | |
$> todos.each do |todo| | |
... puts todo.text | |
... end | |
Learn Ruby on Rails | |
go home happy | |
go to bed | |
=> [{:text=>"Learn Ruby on Rails", :done=>false}, {:text=>"go home happy", :done=>false}, {:text=>"go to bed", :done=>false}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment