In Ruby, is there a difference between writing class Foo::Bar and module Foo; class Bar for namespacing? If so, what?
In Ruby, is there a difference between writing class Foo::Bar and module Foo; class
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.
If you use
class Foo::Bar, but theFoomodule hasn’t been defined yet, an exception will be raised, whereas themodule Foo; class Barmethod will defineFooif it hasn’t been defined yet.Also, with the block format, you could define multiple classes within: