Skip to end of metadata
Go to start of metadata

Sometimes its useful to allow a self reference (to an object being created) in a callable constructor argument. If you try this you will get an "Unknown identifier" error; so declare the object before instantiating it:

class X:
	public f as callable() as string	// f must be public to be called from a passed-in closure
	public s = "hello"
	def constructor(f as callable() as string):
		self.f = f

a as X		// declare it first!
a = X({ return a.s })
print a.f()
  • No labels