lua-users home
lua-l archive

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



On Jan 31, 2005, at 02:51, skaller wrote:

So I think your solution is right because it is most general.

Sounds good :)

In practice, this approach seems to be quite effective as well:

-- instance method to copies all the key-value pairs from the given map
        this.putAll = function( aMap )
                if this.isKindOf( aMap ) then
                        local   someKeys = aMap.keys()
                        local   count = someKeys.size()

                        for index = 1, count do
                                local aKey = someKeys.get( index )
                                local aValue = aMap.get( aKey )

                                this.put( aKey, aValue )
                        end
                elseif type( aMap ) == 'table' then
                        for aKey, aValue in aMap do
                                this.put( aKey, aValue )
                        end
                end

                return this
        end


Cheers

--
PA, Onnay Equitursay
http://alt.textdrive.com/