Search the web
Sign In
New User? Sign Up
groovy-melbourne · The Melbourne GROOVY / GRAILS user group
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Understanding Groovy's Elvis Operator   Message List  
Reply | Forward Message #19 of 39 |

Hello,

Could someone please let me know why this assertion is incorrect. I
hava an Addresss object with three properties. Each time I access the
Address I would like to initialize it with empty strings or keep the
values if they already exist.

class Address
{
String aptNum, poBox, zip

} // Address

class AddressIni
{
Address address;

AddressIni( Address address )
{
this.address = address;
address.aptNum ?: ""
address.poBox ?: ""
}

} // AddressIni

Address address = new Address( aptNum : '300' );

AddressIni ai = new AddressIni(address);

assert "300" == ai.address.aptNum
assert "" == ai.address.poBox ////////// INCORRECT ASSERTION - WHY


Why is the last assertion wrong. I expect the address.poBox property to
be initialized to "" in the AddressIni class. Somehow this does not seem
to happen.



Thanks.







Mon Feb 25, 2008 7:48 pm

z_clair_s
Offline Offline
Send Email Send Email

Forward
Message #19 of 39 |
Expand Messages Author Sort by Date

Hello, Could someone please let me know why this assertion is incorrect. I hava an Addresss object with three properties. Each time I access the Address I...
z_clair_s
Offline Send Email
Feb 25, 2008
7:48 pm

I don't know of the top of my head, but maybe you can try asking here http://www.nabble.com/codehaus---Groovy-f11866.html...
James Ladd
james.ladd
Offline Send Email
Feb 29, 2008
4:53 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help