| 1 |
func test(): |
| 2 |
print("hello %s" % "world" == "hello world") |
| 3 |
print("hello %s" % true == "hello true") |
| 4 |
print("hello %s" % false == "hello false") |
| 5 |
|
| 6 |
print("hello %d" % 25 == "hello 25") |
| 7 |
print("hello %d %d" % [25, 42] == "hello 25 42") |
| 8 |
# Pad with spaces. |
| 9 |
print("hello %3d" % 25 == "hello 25") |
| 10 |
# Pad with zeroes. |
| 11 |
print("hello %03d" % 25 == "hello 025") |
| 12 |
|
| 13 |
print("hello %.02f" % 0.123456 == "hello 0.12") |
| 14 |
|
| 15 |
# Dynamic padding: |
| 16 |
# https://docs.godotengine.org/en/latest/getting_started/scripting/gdscript/gdscript_format_string.html#dynamic-padding |
| 17 |
print("hello %*.*f" % [7, 3, 0.123456] == "hello 0.123") |
| 18 |
print("hello %0*.*f" % [7, 3, 0.123456] == "hello 000.123") |