Forgive my ignorance here, but I’ve been struggling with this for over an hour…
I’m trying to create a function that either accepts 2 integers or 2 floats, but I’m having trouble getting the syntax right:
This is incorrect ReScript, but should describe what I’m after:
type number = int | float
let add = (a: number, b: number) =>
switch a {
| int => a + b
| float => a +. b
}
I suppose I could separate this into 2 functions, but I’m not sure if its the most elegant solution.
Any thoughts on this?