Thanks for the information. And I thought by 2019 we would really be working with highly developed languages. But I guess developers never thought about making it easier on themselves. Or aren't languages created / invented by developers?
My experience is repeated with each new language I attempt... They are all horrible the first month or so. Once I get the syntax and oddities moved to muscle memory, the language gets easier.
Old School:
// Use hub zipcode if a zipcode was not entered
if(zipCode) {
pollenZip = zipCode
} else {
pollenZip = location.zipCode
}
Groovy:
pollenZip = zipCode ? zipCode : location.zipCode
It's highly developed but if you are new to the language, old school makes the transition easier. And let's not forget Elvis ?:
What languages do you program in?
This really threw me:
Which is equivalent to this:
Integer myValue
myValue = 5
myValue = 6
Would you expect myValue to be equal to 5 and 6? You are using an assignment operator there.
I get the feeling you are trying to code by copy and paste and still don't understand how maps and arrays work in Java or in Groovy. I can't comment on the other languages you have experience with, it's been a long time since I played with php (I mean I can comment, but it wouldn't be nice), but I believe the assignment operator works the same way there.
def list1 = ["a", "b", "c"]
def list2 = ["x", "y", "z"]
def counter = 1
def myMap = [:]
list1.each { list1Item ->
myMap."$list1Item" = [:]
list2.each { list2Item ->
myMap."$list1Item"."$list2Item" = counter++
}
}
log.debug myMap
Output:
[a:[x:1, y:2, z:3], b:[x:4, y:5, z:6], c:[x:7, y:8, z:9]]
Nice! Thank you Chuck! (and all others for their contribution of course)
Though I must agree, I've been sleeping while coding. the assignment operator is the same in PHP. And yes, I was being dumb about it. Unfortunately I have to live with myself every time I do stupid things. Sorry for dragging you all in to that too.
But the good news is, I can go on to my next endeavor