forgive if this is too basic of a question,I'm pretty new to scala and been stuck at this particularly.
What I'm trying to achieve is,to have a function which takes an array as arguments,like so :
evenOdd(1,2,3,4,5,6); //where evenOdd is my function
The function definition looks like :
def evenOdd(x : Array[Int] = new Array[Int](6)){
}
It throws an error that too many arguments for the function.How can I achieve passing multiple array integers as fixed size in the function ?
Either pass an Array
to evenOdd
:
evenOdd(Array(1, 2, 3, 4, 5, 6))
or define evenOdd
as:
def evenOdd(x: Int*) = {...}
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