When using class files in Ruby, do you put the ‘requires’ statements at the top of the file, or inside the class definition?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Technically, it doesn’t really matter.
requireis just a normal method call, and the scope it’s called in doesn’t affect how it works. The only difference placement makes is that it will be executed when whatever code it’s placed in is evaluated.Practically speaking, you should put them at top so people can see the file’s dependencies at a glance. That’s the traditional place for it.