Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

clamp should actually accept anything comparable. E.g. clamp("foo", "bar", "baz") should return "baz".


Why wouldn't it return "foo" instead?


Because "bar" < "baz" < "foo". The function signature is: clamp(value, min, max)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: