jeudi 13 août 2015

Name of technique where a function takes a single argument, does some non-mutating work, and returns the same argument?

I find myself wrapping values in a function that does some work, and then simply returns the value again. It seems like it should already have a name, can anyone help me?

shout = (val) ->
    console.log val + " put in safe!"
    return val

safe = []
safe.push "shoe"
safe.push shout("dubloon")

Given the CoffeeScript above, shout could be described as a <half-pipe?> function, and most developers would instantly understand without seeing the implementation.

Aucun commentaire:

Enregistrer un commentaire