Forum Discussion

_ivanovich_'s avatar
_ivanovich_
Frequent Contributor
5 years ago

How to validate all element from an array are less than a value?

Hi, say we have an array like this def my_array = [ [45.26], [44.6],[47.25] ]  def expected = 50 as Float how do you validate that each element are less than 50   i tried this: assert my_array...
  • richie's avatar
    richie
    5 years ago
    Hi _ivanovich_,

    I know youve resolved your issue, but i have a quick question if thats ok for my education really.

    In your array each value was separated by individual square brackets.....why was you doing that? I wouldve thought (without testing your code myself) that your original code wouldve worked if you didnt include the square brackets around each value.....???

    Nice one,

    Rich