Output: How values print
● Beginner3 min
print shows a value the way you would write it in code, so the output is never ambiguous.
type User {
name: String
age: Int
}
fn main() {
const price: Decimal = 499.00
const nickname: String? = none
print(7.0)
print(price)
print('क')
print(["asha", "ravi"])
print(["asha": 31])
print((200, "OK"))
print(nickname)
print(User(name: "Asha", age: 31))
}The program ran and printed:
kavach run values.kav
7.0499.00क["asha", "ravi"]["asha": 31](200, "OK")noneUser(name: "Asha", age: 31)
A Float always shows a point (7.0, never 7), so you can tell it from a whole number. A Decimal keeps its digits (499.00). Text inside a list is quoted, so ["a, b"] can't be mistaken for two items. A record shows its type and fields.
What Kavach does for you
Values print the way you write them
7.0prints7.0, aDecimalkeeps its scale, text inside a list is quoted. Output is never ambiguous.