jastrachan | 10 Mar 23:53 2005
Picon

Re: NULL and Strings

The problem is changing semantics java developers are used to - I'm 
wary of changing the way null works. I'm a big fan of the null object 
pattern so things like this could be possible

def foo = null
def bar = foo.a.b.c.d.e	// notice no NullPointerException
assert bar == null

However this is a bit too much of a leap I think from the Java heritage.

This kinda applies to things like turning nulls into strings and so 
forth on the most part I think.

What might be nice is a way of allowing "" to be the default 
representation of a null object.

e.g.

def foo = null
println "foo is ${foo || ''}"	// use '' as null
println "foo is ${foo || 'nil'}"	// use 'nil' as null

On 10 Mar 2005, at 18:35, Matthew Bellew wrote:
> Simply "" (empty string).
>
> -----Original Message-----
> From: Martin C. Martin [mailto:martin@...]
> Sent: Thursday, March 10, 2005 10:29 AM
> To: user@...
> Subject: Re: [groovy-user] NULL and Strings
>
> Given that null means "object doesn't exist," I'm surprised you can
> convert it to a string without throwing an error.  What do you think 
> the
> result should be?
>
> - Martin
>
>
>

James
-------
http://radio.weblogs.com/0112098/


Gmane