
On Wednesday 23 November 2011, 00:21:33, Lee Short wrote:
That's not my actual code, I was just using it as a simplified example
Glad to read that.
and didn't put a lot of thought into it. My actual code is
if delete /= "" then if exists then deleteFromTable req t key else return () else if exists then updateTable req t key else insertTable req t
I'd love to hear comments on how to make that more idiomatic, if there's a way.
Hmm, harder, much harder. You can replace the if exists then deleteFromTable req t key else return () with when exists (deleteFromTable req t key) and instead of comparing to "", you can use null, so if null delete then if exists then updateTable req t key else insertTable req t else when exists (deleteFromTable req t key) I would recommend the when. Concerning the null vs. /= "", I prefer null, but I'm not religious about it.