Awesome! I thought it was just Java! I'd never seen anyone do it in another language! How would you do it in Lua, though. I was trying for about 20 minutes and couldn't figure it out :O
"In those quiet moments, you come into my mind" - Liam Reilly
local X = {}
function X:foo()
-- do stuff
return self
end
function X:bar()
-- do other stuff
return self
end
function X:hodor()
-- hodor
return self
end
X:foo():bar():hodor()
Well yes, that would make more sense. Although in that example, I would just code the getNames() function to include an argument to get the desired output, so:
Yeah, still just an example. In this case it isn't really neccesary, but especially when dealing with PHP internal functions it can be useful to make the direct modification.
Plus, it breaks your concentration when something that seems to make sense doens't work, at least for me.