简体   繁体   中英

Trying to pass List of Ints as an argument in scala function when calling it

I've written a function with the following signature

def countChange(money: Int, coins: List[Int]): Int = 

When I try to call it and pass arguments I get a type mismatch error

I tried countChange(10, [1, 2]) and countChange(10, List[1, 2]) with no luck

[1,2] is not the syntax for List construction. Lists are not a built in linguistic structure, but just another library. Try countChange(10, List(1,2))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM