I’m learning Groovy. I want an array of numbers from 0 to n with interval 0.1.
double arr=[0,0.1,0.2....n]
I could write a java style for-loop, but is there a easier syntax to do this? I know Groovy has a lot of syntactic sugar.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would go with
0.0..10.0.collect{it/10.0}but maybe there is clever way to do it by specifying increments.