Declarations
"Like most languages I can think of, Wu's data handling is highly based around the concept of variables." - Bruce Lee
Primitives
Variables are highly dependent on types to decide what they want inside them:
As the smart reader might realize, this code is invalid in the way that it's not okay to store numbers in a str
.
By omitting types in you variable declarations, it doesn't mean the variable won't have a type; you simply pass on the job of figuring out the type onto the compiler.
Now would you take a look at all these amazing types:
Casting
Of course, to prevent weird behavior in Wu programs, it's illegal by default to operate values of different types than what is expected. In special scenarios though, it's super useful to be able to use a value as something it isn't(or might be).
This is done using the as
keyword:
With great power comes great responsibility ... the latter, Wu won't bother you with, thus you might get constructive critique for casting things which should not be cast.
Splats
You can declare multiple values at once like the following:
These are also useful for returning multiple values:
Last updated