-
-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
8851654
commit e9791ff
Showing
3 changed files
with
44 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters