lang: funcs: core: fmt: Add variant verb for printf
There's no reason we can't support a %v variant verb. Of course it makes type unification more difficult, and certain uses of this will produce unsolvable situations, but it's useful for debugging, and fun to have.
This commit is contained in:
10
examples/lang/printf0.mcl
Normal file
10
examples/lang/printf0.mcl
Normal file
@@ -0,0 +1,10 @@
|
||||
import "fmt"
|
||||
|
||||
test "printf-a" {
|
||||
anotherstr => fmt.printf("the %s is: %d", "answer", 42),
|
||||
}
|
||||
|
||||
$format = "a %s is: %f"
|
||||
test "printf-b" {
|
||||
anotherstr => fmt.printf($format, "cool number", 3.14159),
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import "fmt"
|
||||
|
||||
test "printf-a" {
|
||||
anotherstr => fmt.printf("the %s is: %d", "answer", 42),
|
||||
anotherstr => fmt.printf("the %v is: %v", "answer", 42),
|
||||
}
|
||||
|
||||
$format = "a %s is: %f"
|
||||
$format = "a %v is: %v"
|
||||
test "printf-b" {
|
||||
anotherstr => fmt.printf($format, "cool number", 3.14159),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user