Is there any intrinsic support for namespacing in coffeescript?
Adequate namespacing seems like something coffeescript could really help with although I don’t seem to be able to find anything to suggest that there is support for this.
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.
A way to make it simple to reference the class both in it’s own “namespace” (the closed function) and the global namespace is to assign it immediately. Example:
As you see, now you can refer to it as
MyClasswithin the file, but if you need it outside it’s available asTest.MyClass. If you only want it in the Test namespace you can simplify it even more: