1
0
forked from Mirror/wren

[0.4.0] Import as (#775)

* Add import "..." for Variable as OtherName
This commit is contained in:
ruby
2020-12-03 09:34:36 -08:00
committed by GitHub
parent 6bd2f810e2
commit 3e0f71b742
6 changed files with 63 additions and 10 deletions

View File

@ -42,6 +42,17 @@ if (thirsty) {
}
</pre>
If you need to import a variable under a different name, you can use
`import "..." for Name as OtherName`. This looks up the top-level variable
`Name` in *that* module, but declares a variable called `OtherName` in *this* module
with its value.
<pre class="snippet">
import "liquids" for Water //Water is now taken
import "beverages" for Coffee, Water as H2O, Tea
// var water = H2O.new()
</pre>
If you want to load a module, but not bind any variables from it, you can omit
the `for` clause: