Skip to content

IntroduceModuleClasses

rollynoel edited this page Jun 15, 2013 · 1 revision

Added by dholton dholton

Creates a module-wide class to hold your code. Moves all the def statements (methods) into this cass, and moves the code that should be executed when a script is run into its own Main method inside the module class.

For example this code:

myarray = (1, 2, 3)
for item in myarray:
	System.Console.WriteLine(item)

is transformed into this:

[Boo.Lang.ModuleAttribute]
public final transient class TempModule:

	private static def Main(argv as (string)) as System.Void:
		myarray = (1, 2, 3)
		for item in myarray:
			System.Console.WriteLine(item)

	private def constructor():
		pass
Clone this wiki locally