Skip to content

Instantly share code, notes, and snippets.

@maliabadi
Created October 26, 2012 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maliabadi/3957484 to your computer and use it in GitHub Desktop.
Save maliabadi/3957484 to your computer and use it in GitHub Desktop.
File Two
# just assuming that 'file_one.rb' is in your desktop directory.
# when you require a file, sometimes you have to specify the exact path of the file you want
require '/Users/jen/Desktop/file_one.rb'
# Now, all of that shit that was in file_one.rb, is in this file's object space.
# So i can do things like.
people.each do |person|
puts "#{person.first_name} is #{person.youth} years old"
end
# see? that variable 'people' that we declared in 'file_one.rb' is already there!
# Also, we already have the specification for the 'Person' class, so we can go ahead and do shit like this.
people << Person.new('robert', 'kelly', 41) # <--- we don't have to redeclare that class again.
people.each do |person|
puts "#{person.first_name} is #{person.youth} years old"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment