Try to search your question here, if you can't find : Ask Any Question Now ?

How would you pop an element from the end of a list in scala, and add it to the end of another list?

HomeCategory: stackoverflowHow would you pop an element from the end of a list in scala, and add it to the end of another list?
julie asked 2 weeks ago

sorry if this is a dumb question but I am currently working with two lists, and I wanted to know what was the best way to pop the last element from one list and add it to the end of another list in Scala? I can’t find the .pop equivalent of Python in Scala so I’m a little confused

For example:

List1[Int] = List(4,5,6)

List2[Int] = List(5,7,8)

From there I want to add the last element of List 2 to List1, and return

List1[Int] = List(4,5,6,8)

List2[Int] = List(5,7)

Any help at all would be appreciated, relatively new to Scala

1 Answers
Best Answer
Fernando answered 2 weeks ago
Your Answer

8 + 8 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com