score:0
Case classes may extend other classes and traits in contrast to Tuple
agglomeration of classes which extend a Product
(see for instance Tuple2).
In the use case here, the case class labels each member which may lead to more readable code, in contrast to the 6-tuple reference (t._1
to t._6
).
score:0
It's convenient to have such data structure for intermediate results. Create classes for results, that returns from your API (or public methods) and use tuples for intermediate results that you discard few lines la
Also, they have some good use cases in collections, for example:
Seq(2,3,4).zipWithIndex.foreach { case (element, index) => println(s"$index:$element") }
score:2
In your example, the case class is clearly a better idea/design. However, one frequent use that I make of tuples is typically when I am handling scala maps, which makes extensive use of them.
Source: stackoverflow.com
Related Query
- What are the use cases for Scala 2.9's try...catch generalization?
- Scala - use cases for tuples?
- Best use cases for currying functions and partially applied functions in scala
- SCALA : Use Cases for extracting particular values from Array
- How to use thenCallRealMethod in Mockito Scala test cases for testing trait method?
- What are the best use cases for Akka framework
- What are some compelling use cases for dependent method types?
- What are some example use cases for symbol literals in Scala?
- Should I use Unit or leave out the return type for my scala method?
- How to use Scala in IntelliJ IDEA (or: why is it so difficult to get a working IDE for Scala)?
- Non-numerical use cases for functional programming?
- Any way to use some Scala for iOS coding?
- Use cases for different sbt Key operators
- Best practice for use constants in scala annotations
- What second language to use besides Scala for LowLevel?
- Redis client library recommendations for use from Scala
- Scala / Lift - Trying to understand Lift's simultaneous claim to use valid html and propensity for lift: tags and tag rewriting in render
- How to use just one scala library for maven/eclipse/scala
- To use or not to use Scala for new Java projects?
- How can I use JMH for Scala benchmarks together with sbt?
- Use '==' instead of equals for string comparison in Scala
- Scala spark: how to use dataset for a case class with the schema has snake_case?
- Scala - Cannot use a method returning play.api.mvc.Result as a Handler for requests
- Scala value class, use cases
- How to Use Circe for Decoding JSON Lists/Arrays in Scala
- Morphia use for Scala
- Which Scala framework to use for testing REST services?
- How to configure IntelliJ to use short package names on "Optimize imports" for a scala codebase?
- How to use an autoincrement index in for comprehension in Scala
- Why does this Scala for expression using tuples fail to compile?
More Query from same tag
- How to access parameters of the underlying model in ML Pipeline?
- In Akka, how do I manage blocking method calls, like reading from StdIn?
- why FunctionN(0-22) ProductN(1-22) TupleN(1-22)?
- Extending Sparks Accumulator
- Scala lists with existential types: `map{ case t => ... }` works, `map{ t => ... }` doesn't?
- How to select a subset of fields from an array column in Spark?
- Running futures sequentially
- Slick lifted update on an Object
- Why is my System.out.println not printing anything in my eclipse plugin?
- How to split a Scala list into sublists based on a list of indexes
- How does scala's array work while its implements are just throwing errors?
- Play2/Scala Custom JSON field validation
- How does Int get converted to BigDecimal?
- <Functional Programing in Scala> simulateMachine
- Using named parameters after partially initialising an object
- Java exception does not propagate to Scala
- System.exit working in "sbt run" but not in .jar
- Most concise way to convert string to integer in Scala?
- Extract Longs from ByteBuffer (Java/Scala)
- Regex with negative look behind still matches certain strings in Scala
- Why is foreach better than get for Scala Options?
- What is the idiomatic (and fast) way of treating the empty list/Seq as failure in a short-circuiting operation?
- How to use return of one gatling request into another request - Scala
- how to update all the values of a column in a dataFrame
- How do I implement neo4j in scala?
- What are performant, scalable ways to resolve links from http://bit.ly
- Associating two arrays in an RDD by index
- Error : java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
- Scala: Create custom OptionT monad from cats for learning
- How to append settings to a sbt project?