{"version":"1.0","published":"2016-04-13 15:32:33","author_url":"https://blog.hatena.ne.jp/obelisk2/","provider_url":"https://hatena.blog","title":"Enumerable \u30e2\u30b8\u30e5\u30fc\u30eb\u306e include\uff08Ruby\uff09","type":"rich","width":"100%","image_url":"http://ecx.images-amazon.com/images/I/51QgbjfMaHL.jpg","provider_name":"Hatena Blog","author_name":"obelisk2","url":"https://obelisk.hatenablog.com/entry/2016/04/13/153233","description":"Enumerable \u30e2\u30b8\u30e5\u30fc\u30eb\u3092 include \u3059\u308b\u3053\u3068\u3067\u3001Enumerable \u306e\u591a\u304f\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u4f7f\u3048\u307e\u3059\u3002\u5fc5\u305a each \u3092\u5b9f\u88c5\u3059\u308b\u3053\u3068\u3002 class SortedList include Enumerable def initialize @data = [] end def <<(element) (@data << element).sort! end def each @data.each {|e| yield(e)} end end if __FILE__ == $0 a = SortedList.new a << 8 a << 1 a << 9 p a #=>#<Sorte\u2026","height":"190","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fobelisk.hatenablog.com%2Fentry%2F2016%2F04%2F13%2F153233\" title=\"Enumerable \u30e2\u30b8\u30e5\u30fc\u30eb\u306e include\uff08Ruby\uff09 - Camera Obscura\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","categories":["Ruby"],"blog_url":"https://obelisk.hatenablog.com/","blog_title":"Camera Obscura"}