3 ms·
in their example, iiuc, DB takes as input the value k, and returns a value of type Optional[k.Value] . The return type depends on the input.
by drdeca 5y ago
in their example, iiuc, DB takes as input the value k, and returns a value of type Optional[k.Value] .
The return type depends on the input.
- jhhh 5y agoI could be missing something but my example does as well since it's a method level generic: Name nameKey = ...; Age ageKey = ...; Optional<String> name = db.get(nameKey); Optional<Integer> age = db.get(ageKey);
- Mehdi2277 5y agoThe difference is your keys are types. Dependent types are about generics where the keys are allowed to be values. You can not in Java directly do, Optional<1> and Optional<“Name”>. You can only have types as arguments. C++ has some dependent types in it allows you to have generic arguments be ints std::array<…, 4> but it still does not allow most values as generic type argument.