Created
January 23, 2016 05:51
-
-
Save ridiculous/05d3405795668b1fb98f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Original | |
name, categories = if product.categorie_names.present? | |
prod_categories = product.category_names.split('>') | |
[prod_categories.pop, prod_categories] | |
end | |
# Refactored using coercion and Ruby's pattern matching | |
*categories, name = *product.categorie_names.to_s.split('>') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment