#Why i need to add a type in std.mem.eql()?

1 messages · Page 1 of 1 (latest)

mossy lily
#

Couldn't it just figure it out with the type of the arguments?

unique topaz
#

It could, but it simplifies the function signature (and code) a lot when you have to pass this coercion type.
You'll see this pattern all over in the stdlib. It makes the code easy to read, I find that it's good for learning.

static skiff
#

If you mean why the signature is (comptime T: type, a: []const T, b: []const T) bool and not something like (a: anytype, b: @TypeOf(a)) bool