Would somebody please explain the said lines in this test?

No - that part I do not agree with.

BTW I got the concept of how the whole thing works, I got that when you people explained it 10 months ago, but I’m a bit confused about the terms bind and pattern-match. How these two terms are related in the context of your sentence I quoted above.

The way I view it: the match operator has a match phase and a bind phase.
Given [p1 = %Product{}, p2 = %Product{}] = Catalog.list_products

During the match phase the match succeeds if
[%Product{}, %Product{}] = Catalog.list_products
is satisfied - otherwise the match fails (this = is the match operator).

Only if the match succeeds do we move to the bind phase. We slap a name on the data that is the first list element and that name is p1 and we also slap a name on the data that is the second list element and that name is p2 (here the = (inside the pattern) simply identifies the data that the name wants to be associated with).

So “binding” is essentially slapping a name on a piece of data (a “value”). “Rebinding” rips the name off of one piece of data like a label and slaps it onto another piece of data. Data is immutable so it never moves - it’s the name that is moving.

2 Likes

Thank you! :slight_smile:

You explained it in a very nice way.

Thank you everyone!

I think, I have to write the summary of all the discussion about this last piece of code we discussed in the end, removing all the repeated questions etc, and then ask for Jose’s comment on that.

1 Like