--0016367fb5f56cdfbe049216b362
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi,

On Fri, Oct 8, 2010 at 9:16 AM, "Martin J. Dst" <duerst / it.aoyama.ac.jp>wrote:

> I would understand that if it were [a, b, c].included? x
> But it's include?, so the order seems just fine. Easy to read as
> "does [a, b, c] include x?". Any other order would feel strange, wouldn't
> it?
>
> Also, an 'in?' method on Object has been proposed, so that you can write
> x.in? [a, b, c]
> That's very short, and fully object oriented pure Ruby, no syntactic sugar
> necessary.


I totally agree : in as keyword is too different than the rest of Ruby
syntax.
I fear this kind of add would make Ruby syntax cryptic...


>
>    3) it is inefficient; new array object is created every times
>>
>
> That's a problem for a good compiler/interpreter. There are many cases in
> Ruby where similar stuff happen, and nevertheless, many people are using
> Ruby. If it really needs to be fast, why not use C or so?
>
>
What about
  x.in?(a, b, c)

The Ruby naive implementation is really simple
  class Object
    def in?(*collections)
      collections.any?{|c| c.include?(self) }
    end
  end
but I guess a C version could add optimizations (but are they needed ?)


Regards,

„Ītienne


-- 
„Ītienne Vallette d'Osia

--0016367fb5f56cdfbe049216b362
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi,<br><br><div class="gmail_quote">On Fri, Oct 8, 2010 at 9:16 AM, &quot;Martin J. Dst&quot; <span dir="ltr">&lt;duerst / it.aoyama.ac.jp&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">


I would understand that if it were [a, b, c].included? x<br>
But it&#39;s include?, so the order seems just fine. Easy to read as<br>
&quot;does [a, b, c] include x?&quot;. Any other order would feel strange, wouldn&#39;t it?<br>
<br>
Also, an &#39;in?&#39; method on Object has been proposed, so that you can write<br>
<a href="http://x.in/" target="_blank">x.in</a>? [a, b, c]<br>
That&#39;s very short, and fully object oriented pure Ruby, no syntactic sugar necessary.</blockquote><div><br>I totally agree : in as keyword is too different than the rest of Ruby syntax.<br>I fear this kind of add would make Ruby syntax cryptic...<br>

/div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 3) it is inefficient; new array object is created every times<br>
</blockquote>
<br></div></blockquote><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
That&#39;s a problem for a good compiler/interpreter. There are many cases in Ruby where similar stuff happen, and nevertheless, many people are usinguby. If it really needs to be fast, why not use C or so?<div class="im">

<br></div></blockquote><div><br>What about <br>x.in?(a, b, c)<br><br>The Ruby naive implementation is really simple<br>class Object<br>def in?(*collections)<br>collections.any?{|c| c.include?(self) }<br>

end<br>end<br></div>
</div>but I guess a C version could add optimizations (but are they needed ?)<br><br><br>Regards,<br><br>±Õienne<br><br><br>-- <br>„Ītienne Vallette d&#39;Osia<br>

--0016367fb5f56cdfbe049216b362--