lua-users home
lua-l archive

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

> As you can see the arguments are inconsistent;
> either (number, content) or (number) or (content)
> Any ideas how to reconcile that?

In cases like this I like having a different constructor for each case:

    b1 =
    b2 = Buffer.fromString("hello world")
    b3 = Buffer.fromBuffer(b2, 14)

One advantage of separating the functions is that if you have a type
error in your code and pass the wrong value to the constructor you get
an error immediately instead of the program silently doing the wrong