News Score: Score the News, Sort the News, Rewrite the Headlines

Abstract methods and NotImplementedError in Ruby

Ruby’s NotImplementedError exception is often used as a placeholder in abstract classes for methods that should be implemented by subclasses. But did you know that this is not how this exception class was intended to be used? How is it commonly (mis)used? Let’s start with an example of a common usage pattern of NotImplementedError. We have a BaseSetting class, and we want to convey that anyone subclassing this should implement a to_html method. class BaseSetting def to_html raise NotImplementedE...

Read more at nithinbekal.com

© News Score  score the news, sort the news, rewrite the headlines