We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Ruby Control Structures - Case (Bonus Question)
Ruby Control Structures - Case (Bonus Question)
Sort by
recency
|
84 Discussions
|
Please Login in order to post a comment
Promotional products serve as powerful tools to strengthen brand visibility—just like Ruby control structures streamline decision-making in code. In the bonus case question, choosing the right
case
statement ensures clean, efficient logic, much like selecting the right branded item ensures lasting customer impact. Whether you're coding with precision or marketing with creativity, the right structure—be it in logic or promotion—leads to better outcomes and a more memorable user experience.Here is Ruby Control Structures - Case (Bonus Question) solution - https://programmingoneonone.com/hackerrank-ruby-control-structures-case-bonus-question-problem-solution.html
why is: *case obj * and not: case obj.class
If you're doing the same thing for each case, a case statement doesn't really make sense in my opinion.
Here's a predicate that includes all of the conditions:
You can use string interpolation (like in truesdell_trent1's comment here ) or just concatenation (with
obj.class.name
) to output the class names.