Delete variable in boo

I know that the similarities between boo and Python are only superficial, but still, how can I make the equivalent of the following Python code in boo?

a = 'a' del a a = 1 

I tried

 a = 'a' a = null System.GC.Collect() System.GC.WaitForPendingFinalizers() a = 1 

But booish tells me that it cannot convert 'int' to 'string'.

It's not about using a duck type. Is it possible?

Change In accordance with the suggestions of the comments, the del value has changed from function to operator.

+4
source share
2 answers

This is not possible in Boo. Boo uses implicit static typing. Thus, all variables are strongly typed based on their first assignment within their scope. Once assigned, the type of the variable cannot change.

Garbage collection ensures that objects on the heap that are no longer referenced will be removed from the heap, but they will not affect the scope of the individual variables of each language. In Boo, a variable does not go out of scope until the end of the block in which it was defined.

The duck introduced in Boo is processed by the compiler, which assigns it a static type of "object", and then uses the runtime code to accomplish the dullness that the underlying .NET runtime considers a common object.

+3
source

you can declare as an object

a as an object a = "letter_a"

print "letter a"

a = 1 print 1

I like boo more than python!

0
source

All Articles