[#382478] Understanding Ruby Inside Out — Konstantin Ka <paranox3@...>

What makes Ruby work?

13 messages 2011/05/01

[#382594] Problem installing shoes3 on RHEL 6 — Ruby Student <ruby.student@...>

I am trying to install/build shoes3 under Red Hat EL 6 and I am having heck

41 messages 2011/05/03
[#382595] Re: Problem installing shoes3 on RHEL 6 — Steve Klabnik <steve@...> 2011/05/03

Two things:

[#382596] Re: Problem installing shoes3 on RHEL 6 — Ruby Student <ruby.student@...> 2011/05/03

Well friend, I can hardly put on a shoe. I am sure I can't build one!

[#382597] Re: Problem installing shoes3 on RHEL 6 — Ruby Student <ruby.student@...> 2011/05/03

Actually, I did try to build my own shoes using the instructions:

[#382598] Re: Problem installing shoes3 on RHEL 6 — Steve Klabnik <steve@...> 2011/05/03

Hm, the last person that got that error said they were using 1.8, but you're

[#382643] Re: Problem installing shoes3 on RHEL 6 — Ruby Student <ruby.student@...> 2011/05/04

Hi Steve,

[#382649] Re: Problem installing shoes3 on RHEL 6 — brabuhr@... 2011/05/04

On Wed, May 4, 2011 at 3:24 PM, Ruby Student <ruby.student@gmail.com> wrote:

[#382652] Re: Problem installing shoes3 on RHEL 6 — Ruby Student <ruby.student@...> 2011/05/04

Brabuhr,

[#382654] Re: Problem installing shoes3 on RHEL 6 — Steve Klabnik <steve@...> 2011/05/04

You have to then reinstall 1.9.2 after installing openssl-devel for it to

[#382658] Re: Problem installing shoes3 on RHEL 6 — Ruby Student <ruby.student@...> 2011/05/04

Well gents,

[#382669] Re: Problem installing shoes3 on RHEL 6 — brabuhr@... 2011/05/04

On Wed, May 4, 2011 at 2:21 PM, Ruby Student <ruby.student@gmail.com> wrote:

[#382698] Re: Problem installing shoes3 on RHEL 6 — Ruby Student <ruby.student@...> 2011/05/05

brabuhr,

[#382699] Re: Problem installing shoes3 on RHEL 6 — brabuhr@... 2011/05/05

> I downloaded your build.

[#382711] Re: Problem installing shoes3 on RHEL 6 — Ruby Student <ruby.student@...> 2011/05/05

Brabuhr,

[#382712] Re: Problem installing shoes3 on RHEL 6 — brabuhr@... 2011/05/05

On Thu, May 5, 2011 at 11:45 AM, Ruby Student <ruby.student@gmail.com> wrote:

[#382713] Re: Problem installing shoes3 on RHEL 6 — brabuhr@... 2011/05/05

> Also try:

[#382715] Re: Problem installing shoes3 on RHEL 6 — Ruby Student <ruby.student@...> 2011/05/05

Here is what I get:

[#382719] Re: Problem installing shoes3 on RHEL 6 — brabuhr@... 2011/05/05

On Thu, May 5, 2011 at 2:50 PM, Ruby Student <ruby.student@gmail.com> wrote:

[#382601] Iterating over an Array of Hashes — Peter Hicks <peter.hicks@...>

All,

23 messages 2011/05/03
[#382607] Re: Iterating over an Array of Hashes — 7stud -- <bbxx789_05ss@...> 2011/05/04

Peter Hicks wrote in post #996483:

[#382609] Re: Iterating over an Array of Hashes — John Feminella <johnf@...> 2011/05/04

On Tue, May 3, 2011 at 20:34, 7stud -- <bbxx789_05ss@yahoo.com> wrote:

[#382612] Re: Iterating over an Array of Hashes — 7stud -- <bbxx789_05ss@...> 2011/05/04

John Feminella wrote in post #996498:

[#382613] Re: Iterating over an Array of Hashes — John Feminella <johnf@...> 2011/05/04

Your example doesn't contain nested hashes, while mine does. That's

[#382616] Re: Iterating over an Array of Hashes — Christopher Dicely <cmdicely@...> 2011/05/04

On Tue, May 3, 2011 at 7:08 PM, John Feminella <johnf@bitsbuilder.com> wrote:

[#382641] Re: Iterating over an Array of Hashes — Chad Perrin <code@...> 2011/05/04

On Wed, May 04, 2011 at 12:28:18PM +0900, Christopher Dicely wrote:

[#382661] Re: Iterating over an Array of Hashes — Christopher Dicely <cmdicely@...> 2011/05/04

>>

[#382650] Creating variables on an OpenStruct with dynamic names — "Jolyon R." <jolyonruss@...>

Hey guys,

11 messages 2011/05/04

[#382686] Lets play a guessing game. (how to code this better?) — Super Goat <ruby-forum@...33mail.com>

I am a new Rubyist. I told my friend that I was learning Ruby. He asked

21 messages 2011/05/05

[#382764] rubygems-update 1.8.1 Released — Eric Hodel <drbrain@...7.net>

rubygems-update version 1.8.1 has been released!

11 messages 2011/05/06

[#382777] Ruby Activity — "Bobby S." <kajisakka@...>

Is ruby still being developed? The official site has last release in dec

25 messages 2011/05/07
[#382782] Re: Ruby Activity — Stu <stu@...> 2011/05/07

Ruby comes with tk build in. While your investigating which toolkits

[#382907] Re: Ruby Activity — "Patrick Lynch" <kmandpjlynch@...> 2011/05/10

I'm using Ruby 1.8.7 and it does not contain TK...

[#382908] Re: Ruby Activity — Eric Christopherson <echristopherson@...> 2011/05/10

On Tue, May 10, 2011 at 2:46 PM, Patrick Lynch <kmandpjlynch@verizon.net> wrote:

[#382933] Re: Ruby Activity — "Patrick Lynch" <kmandpjlynch@...> 2011/05/11

Hi,

[#382938] Re: Ruby Activity — Stu <stu@...> 2011/05/11

If you use macports this is how you enable the variant flag:

[#383075] Git configuration file: .gitconfig — "Patrick Lynch" <kmandpjlynch@...> 2011/05/12

Good morning,

[#382788] Help with while condition OR condition — "Bill W." <sirwillard42@...>

Hi everyone,

14 messages 2011/05/07

[#382795] Threading Loops — "Bobby S." <kajisakka@...>

I understood how to thread functions, but I don't understand how to

14 messages 2011/05/07

[#382903] Ruby 1.9.3 documentation challenge — Eric Hodel <drbrain@...7.net>

With the freeze of Ruby 1.9.3 coming up near the end of the month I looked at how much documentation coverage ruby has for it's standard library:

17 messages 2011/05/10

[#382904] Enumerable#find returns an enumerator? — Roger Pack <rogerpack2005@...>

Hello all.

13 messages 2011/05/10

[#382913] Generate random string matching specific pattern and length — Kevin <darkintent@...>

I'm trying to generate a random set of strings to fill a database with that

10 messages 2011/05/10

[#382916] gsub and multiple-replacement — Greg Hacke <greghacke@...>

So I have a file that I am replicating per user.

11 messages 2011/05/10

[#382991] Scope problem (?) in implementing Design Patterns in Ruby — RichardOnRails <RichardDummyMailbox58407@...>

Hi,

28 messages 2011/05/11

[#383041] Learning Ruby advice needed — Rubist Rohit <passionate_programmer@...>

While learning a new language, I find it very boring to read again the

23 messages 2011/05/12
[#383050] Re: Learning Ruby advice needed — Regis d'Aubarede <regis.aubarede@...> 2011/05/12

> ...I find it very boring to read again the

[#383092] Re: Learning Ruby advice needed — Rubist Rohit <passionate_programmer@...> 2011/05/12

I don't understand how you all feel so comfortable with "irb". It is

[#383046] where does the pure method defined when starting irb — Brian Xue <brxue.cn@...>

Hello,

13 messages 2011/05/12

[#383047] RubyGems 1.8 treats warnings as errors for C extensions, fails to install RedCloth? — Quintus <sutniuq@...>

-----BEGIN PGP SIGNED MESSAGE-----

10 messages 2011/05/12

[#383048] Digest::Base problem — Martin Hansen <mail@...>

I have the following problem:

23 messages 2011/05/12

[#383093] Shell pipeline in Ruby? — Michal Suchanek <hramrach@...>

Hello,

21 messages 2011/05/12

[#383098] Jruby -v failing with possible Java version issue — Ruby Student <ruby.student@...>

Hello team,

11 messages 2011/05/12

[#383144] indenting "end" — Chad Perrin <code@...>

I've been seeing a lot of this lately:

15 messages 2011/05/12

[#383182] ruby.exe crashing on windows xp — "Glory L." <glory.lo778@...>

Hi there,

16 messages 2011/05/13

[#383271] Ruby Future Or? — Robert Johns <piratej74@...>

I was thinking today and I was wondering if ruby has a future when

34 messages 2011/05/15

[#383305] Linux utility with reverse index facility? — no.top.post@...

awk &stuff can "give me the the Nth element",

15 messages 2011/05/16

[#383306] canonical/syntax-diagrams representation. — no.top.post@...

I started investigating ruby.

19 messages 2011/05/16

[#383314] BARRIER - ruby gem - code converter not found (UTF-16LE to IBM737) — Ilias Lazaridis <ilias@...>

After visiting ruby-lang.org, I decided to get the actual 1.9.2

16 messages 2011/05/16

[#383442] Generating Functions in Ruby — Andreas Lundgren <andreas.lundgren.x@...>

Hi!

28 messages 2011/05/18

[#383476] Writing formulas to excel spreadsheet — Will James <ampclj9@...>

Hi, everyone. I've just started using ruby a couple of days ago, and

28 messages 2011/05/19
[#383544] Matz never said Microsoft was the Devil Incarnate. (or did he?) — Mike Stephens <rubfor@...> 2011/05/20

Will

[#383546] Re: Matz never said Microsoft was the Devil Incarnate. (or did he?) — Daniel Berger <djberg96@...> 2011/05/20

[#383552] Re: Matz never said Microsoft was the Devil Incarnate. (or did he?) — Will James <ampclj9@...> 2011/05/21

Daniel Berger wrote in post #999984:

[#383566] Re: Matz never said Microsoft was the Devil Incarnate. (or did he?) — Chad Perrin <code@...> 2011/05/21

On Sat, May 21, 2011 at 11:28:26AM +0900, Will James wrote:

[#383578] Re: Matz never said Microsoft was the Devil Incarnate. (or did he?) — Mike Stephens <rubfor@...> 2011/05/21

Chad Perrin wrote in post #1000098:

[#383604] Re: Matz never said Microsoft was the Devil Incarnate. (or did he?) — Chad Perrin <code@...> 2011/05/22

On Sun, May 22, 2011 at 06:14:10AM +0900, Mike Stephens wrote:

[#383528] BARRIER - ruby yaml - utf-8 characters not human readable — Ilias Lazaridis <ilias@...>

After reading within some archives, it seems that the standard-

10 messages 2011/05/20

[#383534] Object-Oriented thinking — Michael Sokol <mikaa123@...>

Hello everyone,

18 messages 2011/05/20

[#383558] Teaching Ruby in CS1 — Franck Ditter <franck@...>

Who knows some good CS1 references for teaching Python ?

12 messages 2011/05/21

[#383597] BARRIER - json, thin, eventmachine - do not install on windows — Ilias Lazaridis <ilias@...>

I use a fresh installation of ruby 1.9.2p180 to make some tests with

24 messages 2011/05/22

[#383629] Tools for Ruby code analysis — "Alex V." <alex.vpro@...>

Hello everyone,

16 messages 2011/05/23

[#383678] "Local variable within code blocks do not interfere with those outside the block" — Kaye Ng <sbstn26@...>

I read this in a book.

16 messages 2011/05/24

[#383686] Using sprintf() to print a Hash — Iñaki Baz Castillo <ibc@...>

Hi, I just have a single Hash and want to print it into the standar

12 messages 2011/05/24
[#383687] Re: Using sprintf() to print a Hash — Iñaki Baz Castillo <ibc@...> 2011/05/24

2011/5/24 Iñaki Baz Castillo <ibc@aliax.net>:

[#383712] Changes for Ruby in Debian (and Ubuntu) — Lucas Nussbaum <lucas@...>

Hi,

16 messages 2011/05/24

[#383760] Method that mutates object — jason solomon <solomon.jas@...>

Say we want to write a String method called clear that takes a given

26 messages 2011/05/25

[#383770] jruby --1.9 : Exception in thread "RubyThread-1: threadtest.rb:1" java.lang.LinkageError: loader (instance of org/jruby/util/JRubyClassLoader): attempted duplicate class definition for name: "threadtest$block_0$RUBY$true?" — Markus Fischer <markus@...>

Hi,

6 messages 2011/05/25
[#384091] Re: jruby --1.9 : Exception in thread "RubyThread-1: threadtest.rb:1" java.lang.LinkageError: loader (instance of org/jruby/util/JRubyClassLoader): attempted duplicate class definition for name: "threadtest$block_0$RUBY$true?" — Charles Oliver Nutter <headius@...> 2011/06/03

That's wacked. Please file a bug at http://bugs.jruby.org. Looks like

[#383790] CORE - Object Instantiation and Location — Ilias Lazaridis <ilias@...>

#ruby 1.9

17 messages 2011/05/26

[#383810] Need help bringing select array lines together — Paul <tester.paul@...>

Hi there, I am looking at some old, confusing ruby code that works but

12 messages 2011/05/26

[#383961] CORE - Specialized Attribute Definition — Ilias Lazaridis <ilias@...>

ruby 1.9

13 messages 2011/05/31

[#383981] What editor or IDE do you use? — Mike Hansen <skrabbit@...>

I'm pretty new to Ruby. What editor or IDE do you use? I usually use VIM

41 messages 2011/05/31
[#384018] Re: What editor or IDE do you use? — Chad Perrin <code@...> 2011/06/01

(In the following, I will use "vi" to refer to vi-like editors in

[#384021] Re: What editor or IDE do you use? — Stu <stu@...> 2011/06/01

New POLL!!!

[#384022] Re: What editor or IDE do you use? — "Wilde, Donald S" <donald.s.wilde@...> 2011/06/01

Jeez... BSD or Linux... or Doze?

[#384023] Re: What editor or IDE do you use? — Chad Perrin <code@...> 2011/06/01

On Thu, Jun 02, 2011 at 03:09:06AM +0900, Wilde, Donald S wrote:

[#384026] Re: What editor or IDE do you use? — Stu <stu@...> 2011/06/01

You made your point succinctly and eloquently Chad.

[#384027] Re: What editor or IDE do you use? — Xavier Noria <fxn@...> 2011/06/01

Let me add to this thread that the editors of dedicated IDEs are

Re: Understanding Ruby Inside Out

From: Josh Cheek <josh.cheek@...>
Date: 2011-05-01 19:03:03 UTC
List: ruby-talk #382511
On Sun, May 1, 2011 at 1:56 PM, Josh Cheek <josh.cheek@gmail.com> wrote:

> On Sun, May 1, 2011 at 4:29 AM, Konstantin Ka <paranox3@yahoo.de> wrote:
>
>>
>> Would there be any way that Ruby-Newbie-mme could come along, have a
>> look inside the preprogrammed String class and see written there in Ruby
>> language
>>
>> >  def rand
>> >    self.split('').shuffle.join
>> >  end
>>
>> ... because that would enable me to go "Oh, sure! It splits the string,
>> shuffles it, and joins it back together. Sounds easy!" even if, to find
>> out what some of those "1st tier" methods like .split actually do, I'd
>> have to go look at the C code.
>>
>>
>>
> Check out the gem pry (get it by going to the command line and typing "gem
> install pry pry-doc" -- possibly requiring "sudo" privelages, and possibly
> not working on 1.8.6)
>
> Then you can start a pry session with "pry"
>

Sorry I hit space or something, and it sent the message before I finished.
Here is an example session. Pry is a repl (like irb) but it knows how to do
lots of really useful things. One of these is reflecting upon code. In this
case, I tell it to show me the documentation for String#split, then I tell
it to show me the code for String#split For more cool things you can do with
it, check out
http://rdoc.info/github/banister/pry/master/file/README.markdown


$ pry -f


pry(main)> show-doc String#split

From: string.c in Ruby Core (C Method):
Number of lines: 36

Divides str into substrings based on a delimiter, returning an array
of these substrings.

If pattern is a String, then its contents are used as
the delimiter when splitting str. If pattern is a single
space, str is split on whitespace, with leading whitespace and runs
of contiguous whitespace characters ignored.

If pattern is a Regexp, str is divided where the
pattern matches. Whenever the pattern matches a zero-length string,
str is split into individual characters. If pattern contains
groups, the respective matches will be returned in the array as well.

If pattern is omitted, the value of $; is used.  If
$; is nil (which is the default), str is
split on whitespace as if ` ' were specified.

If the limit parameter is omitted, trailing null fields are
suppressed. If limit is a positive number, at most that number of
fields will be returned (if limit is 1, the entire
string is returned as the only entry in an array). If negative, there is no
limit to the number of fields returned, and trailing null fields are not
suppressed.

   " now's  the time".split        #=> ["now's", "the", "time"]
   " now's  the time".split(' ')   #=> ["now's", "the", "time"]
   " now's  the time".split(/ /)   #=> ["", "now's", "", "the", "time"]
   "1, 2.34,56, 7".split(%r{,\s*}) #=> ["1", "2.34", "56", "7"]
   "hello".split(//)               #=> ["h", "e", "l", "l", "o"]
   "hello".split(//, 3)            #=> ["h", "e", "llo"]
   "hi mom".split(%r{\s*})         #=> ["h", "i", "m", "o", "m"]

   "mellow yellow".split("ello")   #=> ["m", "w y", "w"]
   "1,2,,3,4,,".split(',')         #=> ["1", "2", "", "3", "4"]
   "1,2,,3,4,,".split(',', 4)      #=> ["1", "2", "", "3,4,,"]
   "1,2,,3,4,,".split(',', -4)     #=> ["1", "2", "", "3", "4", "", ""]


pry(main)> show-method -l -f String#split

From: string.c in Ruby Core (C Method):
Number of lines: 214

1: static VALUE
2: rb_str_split_m(int argc, VALUE *argv, VALUE str)
3: {
4:     rb_encoding *enc;
5:     VALUE spat;
6:     VALUE limit;
7:     enum {awk, string, regexp} split_type;
8:     long beg, end, i = 0;
9:     int lim = 0;
10:     VALUE result, tmp;
11:
12:     if (rb_scan_args(argc, argv, "02", &spat, &limit) == 2) {
13:     lim = NUM2INT(limit);
14:     if (lim <= 0) limit = Qnil;
15:     else if (lim == 1) {
16:         if (RSTRING_LEN(str) == 0)
17:         return rb_ary_new2(0);
18:         return rb_ary_new3(1, str);
19:     }
20:     i = 1;
21:     }
22:
23:     enc = STR_ENC_GET(str);
24:     if (NIL_P(spat)) {
25:     if (!NIL_P(rb_fs)) {
26:         spat = rb_fs;
27:         goto fs_set;
28:     }
29:     split_type = awk;
30:     }
31:     else {
32:       fs_set:
33:     if (TYPE(spat) == T_STRING) {
34:         rb_encoding *enc2 = STR_ENC_GET(spat);
35:
36:         split_type = string;
37:         if (RSTRING_LEN(spat) == 0) {
38:         /* Special case - split into chars */
39:         spat = rb_reg_regcomp(spat);
40:         split_type = regexp;
41:         }
42:         else if (rb_enc_asciicompat(enc2) == 1) {
43:         if (RSTRING_LEN(spat) == 1 && RSTRING_PTR(spat)[0] == ' '){
44:             split_type = awk;
45:         }
46:         }
47:         else {
48:         int l;
49:         if (rb_enc_ascget(RSTRING_PTR(spat), RSTRING_END(spat), &l,
enc2) == ' ' &&
50:             RSTRING_LEN(spat) == l) {
51:             split_type = awk;
52:         }
53:         }
54:     }
55:     else {
56:         spat = get_pat(spat, 1);
57:         split_type = regexp;
58:     }
59:     }
60:
61:     result = rb_ary_new();
62:     beg = 0;
63:     if (split_type == awk) {
64:     char *ptr = RSTRING_PTR(str);
65:     char *eptr = RSTRING_END(str);
66:     char *bptr = ptr;
67:     int skip = 1;
68:     unsigned int c;
69:
70:     end = beg;
71:     if (is_ascii_string(str)) {
72:         while (ptr < eptr) {
73:         c = (unsigned char)*ptr++;
74:         if (skip) {
75:             if (ascii_isspace(c)) {
76:             beg = ptr - bptr;
77:             }
78:             else {
79:             end = ptr - bptr;
80:             skip = 0;
81:             if (!NIL_P(limit) && lim <= i) break;
82:             }
83:         }
84:         else if (ascii_isspace(c)) {
85:             rb_ary_push(result, rb_str_subseq(str, beg, end-beg));
86:             skip = 1;
87:             beg = ptr - bptr;
88:             if (!NIL_P(limit)) ++i;
89:         }
90:         else {
91:             end = ptr - bptr;
92:         }
93:         }
94:     }
95:     else {
96:         while (ptr < eptr) {
97:         int n;
98:
99:         c = rb_enc_codepoint_len(ptr, eptr, &n, enc);
100:         ptr += n;
101:         if (skip) {
102:             if (rb_isspace(c)) {
103:             beg = ptr - bptr;
104:             }
105:             else {
106:             end = ptr - bptr;
107:             skip = 0;
108:             if (!NIL_P(limit) && lim <= i) break;
109:             }
110:         }
111:         else if (rb_isspace(c)) {
112:             rb_ary_push(result, rb_str_subseq(str, beg, end-beg));
113:             skip = 1;
114:             beg = ptr - bptr;
115:             if (!NIL_P(limit)) ++i;
116:         }
117:         else {
118:             end = ptr - bptr;
119:         }
120:         }
121:     }
122:     }
123:     else if (split_type == string) {
124:     char *ptr = RSTRING_PTR(str);
125:     char *temp = ptr;
126:     char *eptr = RSTRING_END(str);
127:     char *sptr = RSTRING_PTR(spat);
128:     long slen = RSTRING_LEN(spat);
129:
130:     if (is_broken_string(str)) {
131:         rb_raise(rb_eArgError, "invalid byte sequence in %s",
rb_enc_name(STR_ENC_GET(str)));
132:     }
133:     if (is_broken_string(spat)) {
134:         rb_raise(rb_eArgError, "invalid byte sequence in %s",
rb_enc_name(STR_ENC_GET(spat)));
135:     }
136:     enc = rb_enc_check(str, spat);
137:     while (ptr < eptr &&
138:            (end = rb_memsearch(sptr, slen, ptr, eptr - ptr, enc)) >= 0)
{
139:         /* Check we are at the start of a char */
140:         char *t = rb_enc_right_char_head(ptr, ptr + end, eptr, enc);
141:         if (t != ptr + end) {
142:         ptr = t;
143:         continue;
144:         }
145:         rb_ary_push(result, rb_str_subseq(str, ptr - temp, end));
146:         ptr += end + slen;
147:         if (!NIL_P(limit) && lim <= ++i) break;
148:     }
149:     beg = ptr - temp;
150:     }
151:     else {
152:     char *ptr = RSTRING_PTR(str);
153:     long len = RSTRING_LEN(str);
154:     long start = beg;
155:     long idx;
156:     int last_null = 0;
157:     struct re_registers *regs;
158:
159:     while ((end = rb_reg_search(spat, str, start, 0)) >= 0) {
160:         regs = RMATCH_REGS(rb_backref_get());
161:         if (start == end && BEG(0) == END(0)) {
162:         if (!ptr) {
163:             rb_ary_push(result, str_new_empty(str));
164:             break;
165:         }
166:         else if (last_null == 1) {
167:             rb_ary_push(result, rb_str_subseq(str, beg,
168:                               rb_enc_fast_mbclen(ptr+beg,
169:                                      ptr+len,
170:                                      enc)));
171:             beg = start;
172:         }
173:         else {
174:                     if (ptr+start == ptr+len)
175:                         start++;
176:                     else
177:                         start +=
rb_enc_fast_mbclen(ptr+start,ptr+len,enc);
178:             last_null = 1;
179:             continue;
180:         }
181:         }
182:         else {
183:         rb_ary_push(result, rb_str_subseq(str, beg, end-beg));
184:         beg = start = END(0);
185:         }
186:         last_null = 0;
187:
188:         for (idx=1; idx < regs->num_regs; idx++) {
189:         if (BEG(idx) == -1) continue;
190:         if (BEG(idx) == END(idx))
191:             tmp = str_new_empty(str);
192:         else
193:             tmp = rb_str_subseq(str, BEG(idx), END(idx)-BEG(idx));
194:         rb_ary_push(result, tmp);
195:         }
196:         if (!NIL_P(limit) && lim <= ++i) break;
197:     }
198:     }
199:     if (RSTRING_LEN(str) > 0 && (!NIL_P(limit) || RSTRING_LEN(str) >
beg || lim < 0)) {
200:     if (RSTRING_LEN(str) == beg)
201:         tmp = str_new_empty(str);
202:     else
203:         tmp = rb_str_subseq(str, beg, RSTRING_LEN(str)-beg);
204:     rb_ary_push(result, tmp);
205:     }
206:     if (NIL_P(limit) && lim == 0) {
207:     long len;
208:     while ((len = RARRAY_LEN(result)) > 0 &&
209:            (tmp = RARRAY_PTR(result)[len-1], RSTRING_LEN(tmp) == 0))
210:         rb_ary_pop(result);
211:     }
212:
213:     return result;
214: }
pry(main)> exit

In This Thread