Another little thing I often miss (from Java land) is the ability to trim a Str to null. It works just like Str.trim() but goes one step further and returns null should the result be empty.
I miss this because, despite being trivial, it breaks the flow of the code:
data := myStr.trimToNull
vs
data := (Str?) myStr.trim
if (data.isEmpty)
data = null
I usually end up writing a method just so I can inline it:
data := trimToNull(myStr)
Str? trimToNull(Str str) { ...
andyMon 9 Jun 2014
I have used this pattern some - so this could be useful. Not sure I like that name though, but don't have any better suggestions at the moment.
brianMon 9 Jun 2014
I like that, and think trimToNull is decent name. Steve do you want to email me a patch (we should implementation for both Java and JS, plus test in testSys::StrTest)
SlimerDude Fri 6 Jun 2014
Another little thing I often miss (from Java land) is the ability to trim a
Str
tonull
. It works just likeStr.trim()
but goes one step further and returnsnull
should the result be empty.I miss this because, despite being trivial, it breaks the flow of the code:
vs
I usually end up writing a method just so I can inline it:
andy Mon 9 Jun 2014
I have used this pattern some - so this could be useful. Not sure I like that name though, but don't have any better suggestions at the moment.
brian Mon 9 Jun 2014
I like that, and think
trimToNull
is decent name. Steve do you want to email me a patch (we should implementation for both Java and JS, plus test in testSys::StrTest)SlimerDude Wed 11 Jun 2014
Okay, will do.