<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>kwatch</author_name>
  <author_url>https://blog.hatena.ne.jp/kwatch/</author_url>
  <blog_title>kなんとかの日記</blog_title>
  <blog_url>https://kwatch.hatenadiary.org/</blog_url>
  <categories>
    <anon>ruby</anon>
  </categories>
  <description>せっかくなので小ネタを。Python でのリスト内包表記は、for と if を同時に書ける。これはループを1回まわるだけで、選択 (select) と写像 (collect) を一度に行えることを意味する。 &gt;&gt;&gt; L = ['foo', 'bar', 'baz'] &gt;&gt;&gt; [ x.upper() for x in L if x.startswith('ba') ] ['BAR', 'BAZ'] これと同じことを Ruby でやると、Enumerable#collect と #select を使うわけだが、そうするとループを2回まわることになり、アルゴリズム的には動作効率はよくない。 irb…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fkwatch.hatenadiary.org%2Fentry%2F20100330%2F1269956834&quot; title=&quot; Enumerable#select と #collect を同時に行いたい - kなんとかの日記&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2010-03-30 22:47:14</published>
  <title> Enumerable#select と #collect を同時に行いたい</title>
  <type>rich</type>
  <url>https://kwatch.hatenadiary.org/entry/20100330/1269956834</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
