Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAnthony Eriksen
Front End Web Development Techdegree Graduate 16,099 PointsWith mixins and nulls, Why wouldn't you just delete the variable instead of giving it a null value?
The video explains if you don't assigned a value to a variable in a mixin, it will give you an error message. Then by assigning a unnecessary none value, it will assigned that for each instance. But why would you use null? Why not just delete the variable unless you specifically were trying to remove a border which, you could probably avoid by not assigning it a border in the first place?
Maybe i'm way off or missing something.
2 Answers
Samuel Kleos
Front End Web Development Techdegree Student 13,728 PointsThe reason you don't delete the parameter is that you want to be able to pass border values as an argument for your mixin at some point, but perhaps not all the time.
In situations when you pass the argument 'none' for the parameter where you don't need it, you get a line of code that is not needed with a rule (or perhaps) multiple rules with a value of none
.
We don't want that, so we give it a default value of null
. Which means if you don't pass an argument for it, you don't get an error, and the CSS that would normally have been generated as a result of that parameter won't be generated.
Robert Mehew
1,302 PointsIf you have a mixin that sometimes you want to add a border and sometimes you don't, being able to pass null allows you that option without having to write a mixin for every eventuality.
Hope that makes sense, good luck! :)
Samuel Kleos
Front End Web Development Techdegree Student 13,728 Points'Being able to pass null' is a confusing way to put it.
I don't think you pass null into the function as an argument.