1
0
forked from Mirror/wren

Style example output and errors in the docs.

This commit is contained in:
Bob Nystrom
2015-10-18 15:56:52 -07:00
parent 2174ff31e7
commit 545a4cbf7e
24 changed files with 203 additions and 166 deletions

View File

@ -13,7 +13,7 @@ defined, it can be accessed by name as you would expect.
:::wren
var animal = "Slow Loris"
System.print(animal) // Prints "Slow Loris".
System.print(animal) //> Slow Loris
## Scope
@ -22,11 +22,11 @@ until the end of the [block](syntax.html#blocks) where that definition appears.
:::wren
{
System.print(a) // ERROR! a doesn't exist yet.
System.print(a) //! "a" doesn't exist yet.
var a = 123
System.print(a) // "123"
System.print(a) //> 123
}
System.print(a) // ERROR! a doesn't exist anymore.
System.print(a) //! "a" doesn't exist anymore.
Variables defined at the top level of a script are *top-level* and are visible
to the [module](modules.html) system. All other variables are *local*.
@ -38,15 +38,15 @@ intend to do much).
var a = "outer"
{
var a = "inner"
System.print(a) // Prints "inner".
System.print(a) //> inner
}
System.print(a) // Prints "outer".
System.print(a) //> outer
Declaring a variable with the same name in the *same* scope *is* an error.
:::wren
var a = "hi"
var a = "again" // ERROR!
var a = "again" //! "a" is already declared.
## Assignment
@ -65,6 +65,6 @@ assigned value.
:::wren
var a = "before"
System.print(a = "after") // Prints "after".
System.print(a = "after") //> after
**TODO: Top-level names.**