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 trial

Ruby

Icon Mixin during

During the "Create the icon mixin & add iconography" video for the Rails Asset Pipeline and Sass course, Nick Pettit didn't seem to mind repeating himself within his Sass stylesheet which was odd.

Sass authors shouldn't repeat themselves (they should stay 'DRY') and I was surprised he didn't so something like this instead:

$icon-names: arrow-left, new, check, checked, unchecked, close, signout, settings, email                                                                                            
@each $icon-name in $icon-names                                                                                                                                                   
  .icon-#{$icon-name}                                                                                                                                                           
    +icon("icon-#{$icon-name}")

Was there a particular reason he omitted using a loop?

2 Answers

Nick Pettit
STAFF
Nick Pettit
Treehouse Teacher

Hi Kevin,

Great insight! Originally I did have a loop in place, but like a few other things in this project, we omitted them for educational reasons and time constraints. I felt that properly explaining a loop like this would get too far away from the intent of the project, but if I glossed over it, many students might be confused.

Sometimes teaching a project is different than building it, and you have to make some tough calls and strike a balance. I would have rather taught it this way, but even though it's much less code, little lessons like this add up and inflate the run time of a course to the point where it's all theory and no hands-on work. I know it's a little weird, but hopefully that makes sense!

Hi, Nick:

That makes sense. I knew it was odd that the Sass Foundations Deep Dive course wasn't required. I assumed a person taking a class about Sass and Rails should be familiar with Sass.

Thanks for the prompt answer, especially during a three day weekend!