3 ms·
Agh, yes. I already regret putting Java in that list with its wonky implementation. :) But it certainly works with others, e.g. something like this: publi
by dahauns 9y ago
Agh, yes. I already regret putting Java in that list with its wonky implementation. :)
But it certainly works with others, e.g. something like this:
public class SortedList<T> : ICollection<T>,IEnumerable<T> where T : IComparable<T>
- masklinn 9y agoIs that C#? So it does have optional interface implementation? TIL.
- dahauns 9y agoHuh? I'm not sure where you're getting at.
- masklinn 9y agoI'm only asking if the snippet you posted is C# or something else, and noting that if it's C# I have learned something new about the language. Except now that I look at it more specifically, it looks like a bound on the class's generic parameter rather than a condition on the interface implementation? As in you're defining a SortedList class which implements ICollection and IEnumerable but requires T:IComparable, not defining a SortedList class which implements IEnumerable if T is IComparable. And if that reading is correct, Java can do it just fine: class SortedList<T extends Comparable<T>> implements Collection<T>, Iterable<T> however it's got nothing to do with conditional conformance.