feat: replace IO class with System class and remove separate IO module
- Delete wren_io.c, wren_io.h, and io.wren source files - Remove multi-arity print overloads and IO.read/IO.time methods - Add System class with print, printAll, write, writeAll methods to core.wren - Update all documentation examples and README to use System.print instead of IO.print
This commit is contained in:
+12
-12
@@ -58,7 +58,7 @@ To find the value associated with some key, again you use your friend the
|
||||
subscript operator:
|
||||
|
||||
:::dart
|
||||
IO.print(capitals["Idaho"]) // "Boise".
|
||||
System.print(capitals["Idaho"]) // "Boise".
|
||||
|
||||
If the key is present, this returns its value. Otherwise, it returns `null`. Of
|
||||
course, `null` itself can also be used as a value, so seeing `null` here
|
||||
@@ -69,15 +69,15 @@ To tell definitively if a key exists, you can call `containsKey()`:
|
||||
:::dart
|
||||
var belief = {"nihilism": null}
|
||||
|
||||
IO.print(belief["nihilism"]) // "null" though key exists.
|
||||
IO.print(belief["solipsism"]) // Also "null".
|
||||
IO.print(belief.containsKey("nihilism")) // "true".
|
||||
IO.print(belief.containsKey("solipsism")) // "false".
|
||||
System.print(belief["nihilism"]) // "null" though key exists.
|
||||
System.print(belief["solipsism"]) // Also "null".
|
||||
System.print(belief.containsKey("nihilism")) // "true".
|
||||
System.print(belief.containsKey("solipsism")) // "false".
|
||||
|
||||
You can see how many entries a map contains using `count`:
|
||||
|
||||
:::dart
|
||||
IO.print(capitals.count) // "3".
|
||||
System.print(capitals.count) // "3".
|
||||
|
||||
## Removing entries
|
||||
|
||||
@@ -86,12 +86,12 @@ entry you want to delete:
|
||||
|
||||
:::dart
|
||||
capitals.remove("Maine")
|
||||
IO.print(capitals.containsKey("Maine")) // "false".
|
||||
System.print(capitals.containsKey("Maine")) // "false".
|
||||
|
||||
If the key was found, this returns the value that was associated with it:
|
||||
|
||||
:::dart
|
||||
IO.print(capitals.remove("Georgia")) // "Atlanta".
|
||||
System.print(capitals.remove("Georgia")) // "Atlanta".
|
||||
|
||||
If the key wasn't in the map to begin with, `remove()` just returns `null`.
|
||||
|
||||
@@ -100,7 +100,7 @@ can just call `clear()`:
|
||||
|
||||
:::dart
|
||||
capitals.clear()
|
||||
IO.print(capitals.count) // "0".
|
||||
System.print(capitals.count) // "0".
|
||||
|
||||
[lists]: lists.html
|
||||
|
||||
@@ -120,14 +120,14 @@ If you want to see all of the key-value pairs in a map, the easiest way is to
|
||||
iterate over the keys and use each to look up its value:
|
||||
|
||||
:::dart
|
||||
var stateBirds = {
|
||||
var birds = {
|
||||
"Arizona": "Cactus wren",
|
||||
"Hawaii": "Nēnē",
|
||||
"Ohio": "Northern Cardinal"
|
||||
}
|
||||
|
||||
for (state in stateBirds.keys) {
|
||||
IO.print("The state bird of ", state, " is ", stateBirds[state])
|
||||
for (state in birds.keys) {
|
||||
System.print("The state bird of " + state + " is " + birds[state])
|
||||
}
|
||||
|
||||
This program will print the three states and their birds. However, the *order*
|
||||
|
||||
Reference in New Issue
Block a user