This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# append adds its argument as a single element to the end of a list. | |
# The length of the list itself will increase by one. | |
# extend iterates over its argument adding each element to the list, extending the list | |
my_list = [1, 2, 3] | |
my_list.append([4, 5, 6]) | |
# [1, 2, 3, [4, 5, 6]] | |
my_list = [1, 2, 3] | |
my_list.extend(4, 5, 6]) | |
# [1, 2, 3, 4, 5, 6] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// code: | |
handRankCounts.entrySet() | |
.stream() | |
.sorted(Map.Entry.comparingByValue()) // .comparingByValue() returns a comparator so we don't have to build one | |
.forEach(System.out::println); | |
// example output: | |
Four of a kind=1 | |
Straight=1 | |
Three of a kind=3 |
OlderNewer