Skip to content

Instantly share code, notes, and snippets.

@al-the-x
Created May 14, 2015 00:43
Show Gist options
  • Save al-the-x/14276f6bf54bb53ba835 to your computer and use it in GitHub Desktop.
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
$> 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