Re: Returning reference to self does not work

Daniel Wallin <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
Kristoffer Danielsson wrote:
> Luabind 0.8.1
>  
> I can't get this working:
>  
> local x = MyClass('test'):trim()
>  
> MyClass& MyClass::trim()
> {
>    // Modify this object...
>    return *this;
> }
>  
> It seems x is assigned the return value from MyClass('test') instead. Why?

I'm not sure I understand the problem here. What are your expectations?
The above Lua code is equivalent to:

  local y = MyClass('test')
  local x = y:trim()

-- 
Daniel Wallin
BoostPro Computing
http://www.boostpro.com

------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.