lua-users home
lua-l archive

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


> I feel this is worth pointing out:
> > s="ab\0cd"
> > =#s
> 5
> > =s
> ab
> 

This is a misleading example. If you io.write(s) to a file then you'll
get 5 bytes, as expected. (If you io.write(s) to stdout then you'll
get "abcdtrue", which is a bit misterious until you think about who is
printing what. The NUL byte is silently ignored by the terminal, it seems.)

> # applied to a string gives the highest valid index, ignoring any
> "holes". The consistent thing to do would be to make it do the same
> for tables.

A NUL byte in a string is definitely not a "hole".