lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I think i found a problem regarding automatic conversion of data types to string. Here is an example of a Lua script:

-- cut here --
print("Type: ",type(numericValue))
print("Value: ",numericValue)
print("Some string "..numericValue)

print("Type: ",type(boolValue))
print("Value: ",boolValue)
print("Some string "..boolValue)
-- end cut --

The output is:

-- cut here --
Type: 	number
Value: 	123.456
Some string 123.456
Type: 	boolean
Value: 	true
lua: aa:9: attempt to concatenate global 'boolValue' (a boolean value)
stack traceback:
	aa:9: in main chunk
	[C]: ?
-- end cut --

I see that for number type there is an automatic conversion to string. Why boolean makes an exception?

Thank you