Module:String

From hyperspacewiki
Revision as of 04:20, 19 December 2018 by Jflopezfernandez (talk | contribs) (s1 = "Hello, world")
Jump to: navigation, search

String Module

The original source code for this module was taken from the Wikipedia String Module but had to be re-written because the Wikipedia code used an overly general method for getting the function parameters that resulted in a null reference error. I simplified the argument referencing which solved the error.

Functions

Length

Returns the length of the passed-in string.


local str = {}

function str:len( frame )
    local new_args = str._getParameters( frame.args, {'s'} );
    local s = new_args['s'] or '';
    
    return mw.ustring.len( s )
end