|
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.
|