Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

groovy bug? -- creating an initialized float array?

Tags:

grails

groovy

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

like image 457
Ray Avatar asked Feb 23 '23 13:02

Ray


1 Answers

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]
like image 67
socha23 Avatar answered Feb 25 '23 14:02

socha23