Back in 2016, Li Haoyi put together this nice article titled, Benchmarking Scala Collections.
I prefer the phrase, “Sun does not set.” #talkeetna #alaska
If you want to automatically generate getters and setters for your Java JavaBean classes, Project Lombok has some annotations that you can use.
I have no idea what I was thinking, but today I learned (or was reminded) that if you want the first element from a Scala
Set you should use its
head method, or
headOption. For some reason I kept thinking that
take should do the job, but you can see the results in the Scala REPL, where
take(1) returns a
With Kotlin you can create lists, maps, and sets with standard functions that are automatically in scope. Here are those functions.
A visual image of the mathematical concept of “sets” using southern colloquialisms.
(I found this image on Twitter, but since I didn’t “like” it at the time I can’t find who created it, but I’ll link to them if/when I ever find the page again.)
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 11.28, “How to Use Sortable Sets in Scala”
You want to be able to store and retrieve items from a set in a sorted order.
To retrieve values from a set in sorted order, use a
SortedSet. To retrieve elements from a set in the order in which elements were inserted, use a
SortedSet returns elements in a sorted order:
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 11.27, “How to Delete Elements from Sets in Scala”Back to top
You want to remove elements from a mutable or immutable set.Back to top
Mutable and immutable sets are handled differently, as demonstrated in the following examples.Back to top
When working with a mutable
Set, remove elements from the set using the
--= methods, as shown in the following examples:
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 11.26, “How to Add Elements to a Set in Scala”
You want to add elements to a mutable set, or create a new set by adding elements to an immutable set.
Mutable and immutable sets are handled differently, as demonstrated in the following examples.
Add elements to a mutable
Set with the
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 10.21, “How to Extract Unique Elements from a Scala Sequence”
You have a collection that contains duplicate elements, and you want to remove the duplicates.
distinct method on the collection: