Halloween Sale: Flat 70% + Addl. 25% Off + 30 Days Extra Lab on all Courses | Use Coupon HS25 in Checkout | Offer Expires In

  Enroll Now

Scala - Assessment - Declare an array with range

One of the ways to define an array in Scala just to provide the range, instead of mentioning all the elements in the array definition.

We need to use range keyword for such purposes. For example, range(1,5,1) will define an array equivalent to (1,2,3,4) where first 2 arguments, '1' and '5' are range, and third argument '1' is incremental value. Note that the resulting array doesn't include the second argument, that is '5' in this case.

  • Switch to Jupyter tab.

  • Import Array._ in order to use the range function.

  • Declare an array of numbers, named numArray, having elements from 10 to 20 with an increment of 2.

  • Press Shift+Enter.

  • Submit your answer.

No hints are availble for this assesment

Answer is not availble for this assesment

Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...