I have a method
def foo(num: Int): String
Where I call some in some places in my code, and everything was good.
Lately, I encountered a situation where I need to call the same method, but with some parameter int value, I need to get in return 2 Strings, and not only one. My current way of implementing it is:
def foo(num: Int): List[String]
Where each time I call foo
and get 1 String, I will get the head of the list, and each time I call for and it returns 2 strings, I will get the elements in [0, 1] (I know that when I call foo(10)
, I get 2 strings, and for the rest - only one).
Is there a more idiomatic scala/functional for this?
See Question&Answers more detail:os