Imagine an original question that goes like this:
Q: How do I do this thing? When I do it the "wrong way" it works until I try to do this other thing afterwards
A: You don't want to do it like that, here is the "right way" to do it.
Now a question comes along that goes like this:
Q: How do I do this thing? The "right way" works, but I don't like it
A: Do it this "wrong way".
Is the second question a duplicate of the first? The solution the OP of the second question wants is found in the original question's question, not its answer.
The motivation behind this question is this question: Append unit type to the result of a calculation
I closed it as a duplicate when I was going through a pile of similar questions (I have the gold badge for sass), but the OP didn't like that and convinced 5 people that it wasn't a duplicate and had it reopened. This is the question I used to close it with: Adding a unit to a number in Sass
To make things worse, this question is now the #1 result on Google when you search for "sass append unit". I realize that whether the solution is "right" or "wrong" might be a matter of opinion, but the "wrong" way has been perpetuated so often that it repeatedly trips up users who don't know any better. This question being the one users are going to turn to first is only making things worse.
If you look at the other top results, they either get it right or are not relevant:
- https://css-tricks.com/snippets/sass/correctly-adding-unit-number/
- http://www.sitepoint.com/understanding-sass-units/
- Official documentation for functions, nothing relevant here
- https://groups.google.com/forum/#!topic/sass-lang/4uHbZ9OL48Q
- Not relevant
- Not relevant
- Not relevant
- Not relevant
- http://sass-guidelin.es/
From CSS Tricks:
While this method works, it is far from ideal because it results in implicitly casting the initial value as a string. Indeed, if you try doing math with the $length value from now on, you'll see that Sass quickly throws an error because it cannot do math operators with a string.
From Chris Eppstein, one of the maintainers of Sass, on Google Groups:
No, don't do this. $width_value will be a string that looks like a number instead of a number.
From Sass Guidelines:
The most common mistake I can think of regarding numbers in Sass, is thinking that units are just some strings that can be safely appended to a number. While that sounds true, it is certainly not how units work. Think of units as algebraic symbols. For instance, in the real world, multiplying 5 inches by 5 inches gives you 25 square inches. The same logic applies to Sass.
We are doing a real disservice to our users by not pointing them to the correct answer, which we already have in multiple places on SO.