Browse Source

Add string interpolation documentation

David Peter 2 years ago
parent
commit
f2f4882c13
2 changed files with 9 additions and 3 deletions
  1. 0 2
      book/src/example-pipe_flow_rate.md
  2. 9 1
      book/src/procedures.md

+ 0 - 2
book/src/example-pipe_flow_rate.md

@@ -8,8 +8,6 @@
 # viscosity of water and allows for inputs of pipe radius,
 # pipe length, and pressure difference.
 
-dimension FlowRate = Volume / Time
-
 let μ_water: DynamicViscosity = 1 mPa·s
 
 fn flow_rate(radius: Length, length: Length, Δp: Pressure) -> FlowRate =

+ 9 - 1
book/src/procedures.md

@@ -9,6 +9,14 @@ print(2 km/h)
 print(3 ft < 1 m)
 ```
 
+You can also print out simple messages as strings. This is particularly useful when combined
+with string interpolation to print results of a computation:
+
+```nbt
+let radius: Length = sqrt(footballfield / 4 pi) -> meter
+print("A football field would fit on a sphere of radius {radius}")
+```
+
 ## Testing
 
 The `assert_eq` procedure can be used to test for (approximate) equality of two quantities.
@@ -29,7 +37,7 @@ assert_eq(1 ft × 77 in², 4 gal)
 
 assert_eq(alpha, 1 / 137, 1e-4)
 assert_eq(3.3 ft, 1 m, 1 cm)
-``` 
+```
 
 A runtime error is thrown if an assertion fails. Otherwise, nothing happens.