In this lesson we'll take some existing code and refactor it using some functions from the Ramda library, most notably, compose
and converge
. When we're done, we'll have taken a function with a couple of local variables and parameter references and converted it into more streamlined "point-free" or "tacit" functions.
I don't understand the benefit here. We could have just added a default value to the id
parameter in case it was null:
const generateUrl = (id = 'default') => `https://img.socialnetwork.com/avatar/${id}.png`
The way we've refactored with Ramda is looks more confusing and harder to understand. I'm not familiar with Ramda yet maybe I'll see the point by the end of the course.
How is this the first episode of the series? It just jumps right in without explaining half of what is going on?
Very tough for a first lesson. Watched it several times and it's still hard to grasp. End result is not very clear to read either. Must be better examples to show benefits of ramda.
@Brendan, in your example, if generateUrl
is called with null
, then your result will be "https://img.socialnetwork.com/avatar/null.png"
, which is not what you want.
With the new nullish coalescing operator, we only need to do this:
const generateUrl = (id) => `https://img.socialnetwork.com/avatar/${id ?? 'default'}.png`
I don't understand the benefit here. We could have just added a default value to the
id
parameter in case it was null:
Off the cuff, I'd say composability.