You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, new guy trying to learn how to program scala2. For that purpose I have been completing the challenges from AOC.
My issue with scala starts when I need a set to operate with a custom data type. The 2 core references are: old web laguange reference and the library reference. In neither is specified how or what specific traits (personal assumption) must be implemented by the type for it to work correctly with the collection.
For example in ADA the set has this small definition where it defines all the methods expected from the class used in the set.
generic
type Element_Type is private;
with function "<" (Left, Right : Element_Type) return Boolean is <>;
with function "=" (Left, Right : Element_Type) return Boolean is <>;
To put another example, in C++ the set has the definitions for a class/method to provide the functionality.
template<
class Key,
class Hash = std::hash<Key>,
class KeyEqual = http://en.cppreference.com/w/cpp/utility/functional/equal_to<Key>,
class Allocator = http://en.cppreference.com/w/cpp/memory/allocator<Key>
> class unordered_set;
To not go so far away, in java defines the set as follows:
A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1 and e2 such that e1.equals(e2), and at most one null element. As implied by its name, this interface models the mathematical set abstraction.
I would like the inclusion of a clear way of utilization of collections with custom types, even better if it was also provided with examples.
Thank you and kind regards,
Gugo
The text was updated successfully, but these errors were encountered:
Hello, new guy trying to learn how to program scala2. For that purpose I have been completing the challenges from AOC.
My issue with scala starts when I need a set to operate with a custom data type. The 2 core references are: old web laguange reference and the library reference. In neither is specified how or what specific traits (personal assumption) must be implemented by the type for it to work correctly with the collection.
For example in ADA the set has this small definition where it defines all the methods expected from the class used in the set.
To put another example, in C++ the set has the definitions for a class/method to provide the functionality.
To not go so far away, in java defines the set as follows:
I would like the inclusion of a clear way of utilization of collections with custom types, even better if it was also provided with examples.
Thank you and kind regards,
Gugo
The text was updated successfully, but these errors were encountered: