lua-users home
lua-l archive

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


Peter Aronoff <telemachus@arpinum.org> wrote:
> Here’s one that somebody suggestsed for a module of mine. The module is
> named split, and the primary method is also split. So if you require it in
> a conventional way, you get this:
> 
> 	local split = require "split"
> 	local record = "foo,bar,bizz,buzz"
> 	local fields = split.split(record)

How embarrassing: I was so focused on getting to the magic of making the
table that stores the module callable that I got my own split method wrong!
That last line should be this:

	local fields = split.split(record, ",")

It doesn’t much matter, but I don’t want people thinking that the split
method itself can magically determine what to split on! (Splitting on nil
actually defaults to a pattern of "%s+", which is what some scripting
languages default to in that situation.)

Best, P
-- 
We have not been faced with the need to satisfy someone else's
requirements, and for this freedom we are grateful.
    Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System