New Method

BlitzMax Forums/BlitzMax Programming/New Method

Funny thing is that if you change new to a function, it will tell you it must be a method?

Thats because the method "NEW" exists as a method of the base object, (This may not be correct, cos intuitivly you would think it would be a function)

What you are doing is creating a method that is called after the base "New"
SuperStrict

Type MyType
	
	Field MyField:Int
	
	Method New:MyType()
		MyField=10
		Print "Hello"
	End Method

EndType

Local Variable:MyType = New MyType
Print Variable.MyField
I am very supprised to hear that it excepts parameters, cos I dont think it should.

You do this, when you want to add each instance to a list or such, or you need a more dynamic creation. (Well realy I dont think you should ever do it, and think MyType.Create:MyType(Params) is better)