One Class per "Module" .monkey file (import fun)

Monkey Forums/Monkey Programming/One Class per "Module" .monkey file (import fun)

Yahfree(Posted 2014) [#1]
Hey, maybe I'm just used to writing in Java style(One class per file), but is there a way to write in this style without having to write "ClassName.ClassName"?

What I mean is having main.monkey file, which starts the program, and then having all the rest of the code be split such that each MyClass.monkey file contains a single class MyClass.

You can import each class into the main.monkey file, however you cannot access that class without using "MyClass.MyClass" since you're accessing the module namespace.

Thanks


muddy_shoes(Posted 2014) [#2]
Don't have your filenames matching the case of the class name. Lower case them, i.e. classname.monkey holding the ClassName class.


AdamRedwoods(Posted 2014) [#3]
you can alias as well
Alias myclass = modulename.myclass

...but you can access a class without the module name. it becomes a problem when there's duplicates, and you can use alias to work around that.


Yahfree(Posted 2014) [#4]
Thanks. Ended up going with Muddy_Shoe's suggestion.