Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBlair Rorani
6,658 PointsAre there rules for naming variables that store new objects?
"We can create a new Post object by calling Post.new. We can create a new "Post" and assign it to a variable: post = Post.new"
Do we need to name the variable "post" because we're creating a new Post object? Or can we call it anything.
1 Answer
Elisa Burghard
9,276 PointsAs far as I understand it, you can generally name the variables anything you want, "pizza", "pasta", "post". Since it's likely that other developers will read your code and work with it, always give the variables sensible names. The naming convention that you should follow is: the classname will be capitalized Post, the ruby file will be named post.rb (another example: class SportsCar will be in a file called sports_car.rb).
Hope this helps and happy coding!