[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: [].require with inject didn't throw an exception - is a bug?
From:       Dan Fitzpatrick <dan () eparklabs ! com>
Date:       2017-07-25 21:04:33
Message-ID: 81BA0C7A-BAB1-4A73-8B2B-0162725DA190 () eparklabs ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


The symbol form of inject will call a kernel method and pass each array element as \
the first arg.


On Jul 25, 2017, at 2:50 PM, Arup Rakshit <aruprakshit@rocketmail.com> wrote:

> Hello Dan,
> 
> Thanks for explaining it. But on which object the length method is being called? If \
> `[]` is not the receiver object? 
> Thanks,
> ~A
> 
> 
> 
> > On Jul 26, 2017, at 1:20 AM, Dan Fitzpatrick <dan@eparklabs.com> wrote:
> > 
> > So: ['aa'].inject([], :length) is trying to call:
> > 
> > length ‘aa’
> 
> 
> Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>


[Attachment #5 (unknown)]

<html><head><meta http-equiv="Content-Type" content="text/html \
charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: \
space; -webkit-line-break: after-white-space;"><div apple-content-edited="true"><div \
style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; \
text-indent: 0px; text-transform: none; white-space: normal; widows: auto; \
word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; \
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="color: \
rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: \
0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; \
-webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; \
-webkit-line-break: after-white-space;"><div>The symbol form of inject will call a \
kernel method and pass each array element as the first \
arg.</div><div><br></div><div><br></div></div></div></div><div><div>On Jul 25, 2017, \
at 2:50 PM, Arup Rakshit &lt;<a \
href="mailto:aruprakshit@rocketmail.com">aruprakshit@rocketmail.com</a>&gt; \
wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta \
http-equiv="Content-Type" content="text/html charset=utf-8"><div style="word-wrap: \
break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" \
class=""><div class="">Hello Dan,</div><div class=""><br class=""></div><div \
class="">Thanks for explaining it. But on which object the length method is being \
called? If `[]` is not the receiver object?</div><br class=""><div class=""> <div \
style="font-family: Courier; font-size: 12px; font-style: normal; font-weight: \
normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; \
text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; \
-webkit-text-stroke-width: 0px;">Thanks,</div><div style="font-family: Courier; \
font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; \
orphans: auto; text-align: start; text-indent: 0px; text-transform: none; \
white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: \
0px;">~A</div><div style="font-family: Courier; font-size: 12px; font-style: normal; \
font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; \
text-indent: 0px; text-transform: none; white-space: normal; widows: auto; \
word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><br \
class="Apple-interchange-newline"> </div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Jul 26, 2017, at \
1:20 AM, Dan Fitzpatrick &lt;<a href="mailto:dan@eparklabs.com" \
class="">dan@eparklabs.com</a>&gt; wrote:</div><br \
class="Apple-interchange-newline"><div class=""><span style="font-family: Courier; \
font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; \
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; \
white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; \
display: inline !important;" class="">So: ['aa'].inject([], :length) is trying to \
call:</span><br style="font-family: Courier; font-size: 12px; font-style: normal; \
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: \
start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: \
0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Courier; \
font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; \
letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; \
white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" \
class=""><span style="font-family: Courier; font-size: 12px; font-style: normal; \
font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: \
start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: \
0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" \
class="">length ‘aa’</span></div></blockquote></div><br \
class=""></div><br>Unsubscribe: &lt;<a \
href="mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe">mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe</a>&gt;<br>&lt;<a \
href="http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk">http://lists.ruby- \
lang.org/cgi-bin/mailman/options/ruby-talk</a>&gt;<br></blockquote></div><br></body></html>




Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic