I'm using Groovy 1.8.3 (in Grails 2.0). I need to declare some float arrays, and am using the standard java syntax, e.g.:
float rentVal[] = {1.37f, 1.69f, 2.07f, 2.53f}
The compiler errors on this, saying: expecting '}', found '='
Perhaps because it's late night (pacific time) I'm confusing something here. My question is what's the right way to do this in Groovy.
Thanks
Tried this in GroovyConsole:
groovy> def rentVal = [1.37f, 1.69f, 2.07f, 2.53f] as float[]
groovy> rentVal.class
Result: class [F
EDIT, it's enough to do this:
float[] a = [1.0f, 2.3f, 3.4f]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With