lua-users home
lua-l archive

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


Hi,

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

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

boolValue=true
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