Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
51
Task/Variables/Nanoquery/variables.nanoquery
Normal file
51
Task/Variables/Nanoquery/variables.nanoquery
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
// variable definition and initialization/assignment
|
||||
//
|
||||
// variables are initialized when they are defined
|
||||
a = 1
|
||||
b = 2
|
||||
c = null
|
||||
|
||||
// datatypes
|
||||
//
|
||||
// variables may contain any datatype, and this can be
|
||||
// changed at any time by assigning a new value. they may
|
||||
// also contain native java types
|
||||
var = "a string"
|
||||
var = 123
|
||||
var = new(Nanoquery.Util.Random)
|
||||
var = new(java.lang.Object)
|
||||
|
||||
// scope
|
||||
//
|
||||
// all classes, functions, and control blocks have their
|
||||
// own scope
|
||||
x = 5
|
||||
for i in range(1, 2)
|
||||
// we can reference 'x' within this loop without issue
|
||||
println x
|
||||
|
||||
// we can also define variables that have this loop as their
|
||||
// scope
|
||||
y = 5
|
||||
end
|
||||
// trying to reference the variable 'y' outside of its scope would result
|
||||
// in a null reference exception
|
||||
println y
|
||||
//%null reference exception: variable object 'y' has not been defined
|
||||
// at <global>:33
|
||||
|
||||
|
||||
// referencing
|
||||
//
|
||||
// as already demonstrated, variables are referenced by using their
|
||||
// name
|
||||
part1 = "this is "
|
||||
part2 = "a test sentence"
|
||||
println part1 + part2
|
||||
|
||||
// other facilities
|
||||
//
|
||||
// variables may be marked for garbage collection in their current
|
||||
// scope using the 'delete' command
|
||||
test_var = "pretend this is a really large object we want to free up"
|
||||
delete test_var
|
||||
Loading…
Add table
Add a link
Reference in a new issue