[#390749] Why are there so many similar/identical methods in core classes — Kassym Dorsel <k.dorsel@...>

Let's look at the Array class and start with method aliases.

14 messages 2011/12/02

[#390755] Inverse Operation of Module#include — Su Zhang <su.comp.lang.ruby@...>

Hi list,

21 messages 2011/12/02
[#390759] Re: Inverse Operation of Module#include — Ryan Davis <ryand-ruby@...> 2011/12/02

[#390764] Re: Inverse Operation of Module#include — Isaac Sanders <isaacbfsanders@...> 2011/12/02

I would suggest an Adapter pattern use here. IF there is something that has

[#390876] black magical hash element vivification — Chad Perrin <code@...>

Ruby (1.9.3p0 to be precise, installed with RVM) is not behaving as I

12 messages 2011/12/05

[#390918] WEB SURVEY about Ruby Community — Intransition <transfire@...>

Did any one else get this survey request?

14 messages 2011/12/07

[#390976] Confusing results from string multiplication — Rob Marshall <robmarshall@...>

Hi,

19 messages 2011/12/08

[#391019] How can I do h["foo"] += "bar" if h["foo"] does not exist? — "Andrew S." <andrewinfosec@...>

Hi there,

13 messages 2011/12/09

[#391027] reading from file without end-of-lines — Janko Muzykant <umrzykus@...>

hi,

20 messages 2011/12/09
[#391028] Re: reading from file without end-of-lines — Gavin Sinclair <gsinclair@...> 2011/12/09

> i'm trying to read a few text values from single file:

[#391031] Re: reading from file without end-of-lines — Robert Klemme <shortcutter@...> 2011/12/09

On Fri, Dec 9, 2011 at 9:58 AM, Gavin Sinclair <gsinclair@gmail.com> wrote:

[#391042] Re: reading from file without end-of-lines — Gavin Sinclair <gsinclair@...> 2011/12/09

On Fri, Dec 9, 2011 at 8:18 PM, Robert Klemme

[#391135] I need advice on what to do next. — Nathan Kossaeth <system_freak_2004@...>

I am new to programming. I read the ebook "Learn to Program" by Chris

23 messages 2011/12/12

[#391216] perf optimization using profile results — Chuck Remes <cremes.devlist@...>

I need some help with optimizing a set of libraries that I use. They are ffi-rzmq, zmqmachine and rzmq_brokers (all up on github).

13 messages 2011/12/13
[#391218] Re: perf optimization using profile results — Chuck Remes <cremes.devlist@...> 2011/12/13

On Dec 13, 2011, at 9:57 AM, Chuck Remes wrote:

[#391234] Re: perf optimization using profile results — Charles Oliver Nutter <headius@...> 2011/12/14

A couple quick observations.

[#391238] Re: perf optimization using profile results — Chuck Remes <cremes.devlist@...> 2011/12/14

On Dec 13, 2011, at 7:03 PM, Charles Oliver Nutter wrote:

[#391324] ruby 1.9 threading performance goes non-linear — Joel VanderWerf <joelvanderwerf@...>

12 messages 2011/12/16
[#391325] Re: ruby 1.9 threading performance goes non-linear — Eric Wong <normalperson@...> 2011/12/16

Joel VanderWerf <joelvanderwerf@gmail.com> wrote:

[#391420] Accessing class instance variables from an instance? — "Shareef J." <shareef@...>

Hi there,

26 messages 2011/12/20
[#391454] Re: Accessing class instance variables from an instance? — Khat Harr <myphatproxy@...> 2011/12/21

Actually, now that I'm thinking about it the existing behavior sort of

[#391456] Re: Accessing class instance variables from an instance? — Josh Cheek <josh.cheek@...> 2011/12/21

On Tue, Dec 20, 2011 at 9:42 PM, Khat Harr <myphatproxy@hotmail.com> wrote:

[#391545] Kernel#exit raises an exception? — Khat Harr <myphatproxy@...>

While I was working on embedding an interpreter I wrote a function to

13 messages 2011/12/24

[#391618] rvmsh: An easy installer for RVM — Bryan Dunsmore <dunsmoreb@...>

I have recently begun work on a project called [rvmsh]

12 messages 2011/12/29

[#391783] Mailspam — Gunther Diemant <g.diemant@...>

Is there a way to stop this mailspam of Luca (Mail)?

12 messages 2011/12/29

[#391790] What’s the standard way of implementing #hash for value objects in Ruby? — Nikolai Weibull <now@...>

Hi!

23 messages 2011/12/29
[#391792] Re: What’s the standard way of implementing #hash for value objects in Ruby? — Gunther Diemant <g.diemant@...> 2011/12/29

I think you can't access instance variables from a class method, so

[#391793] Re: What’s the standard way of implementing #hash for value objects in Ruby? — Nikolai Weibull <now@...> 2011/12/29

On Thu, Dec 29, 2011 at 15:52, Gunther Diemant <g.diemant@gmx.net> wrote:

[#391811] Re: What’s the standard way of implementing #hash for value objects in Ruby? — Robert Klemme <shortcutter@...> 2011/12/29

On Thu, Dec 29, 2011 at 4:06 PM, Nikolai Weibull <now@bitwi.se> wrote:

[#391812] Re: What’s the standard way of implementing #hash for value objects in Ruby? — Nikolai Weibull <now@...> 2011/12/29

On Fri, Dec 30, 2011 at 00:26, Robert Klemme <shortcutter@googlemail.com> w=

[#391816] Re: What’s the standard way of implementing #hash for value objects in Ruby? — Josh Cheek <josh.cheek@...> 2011/12/30

On Thu, Dec 29, 2011 at 5:47 PM, Nikolai Weibull <now@bitwi.se> wrote:

[#391833] Re: What’s the standard way of implementing #hash for value objects in Ruby? — Robert Klemme <shortcutter@...> 2011/12/30

On Fri, Dec 30, 2011 at 12:47 AM, Nikolai Weibull <now@bitwi.se> wrote:

Re: Learn To Program (Chris Pine) - Building and Sorting Array

From: Emeka Patrick <emekapatrick@...>
Date: 2011-12-09 23:02:02 UTC
List: ruby-talk #391073
Hi John,

Thanks so much for getting back to me and for your kind words. Really 
big encouragement for someone just starting out and feeling a wee bit 
lost at times. As well, I must say the willingness of people in the Ruby 
community to offer help has really been pretty amazing.

John W Higgins wrote in post #1036028:
> Good Day Emeka,
>
> On Fri, Dec 9, 2011 at 12:47 PM, Emeka Patrick
> <emekapatrick@gmail.com>wrote:
>
>> Hi Robert,
>>
>> Thanks so much for getting back to me on this much appreciated. Some
>> questions in-line below.
>>
>
> Thank you for at least attempting to figure things out. Very refreshing
> in
> contrast to some of the questions that people pose here........

Thanks a bunch. Want to make sure I truly understand how and why things 
work when they do (or when they don't!)

>> >
>> >> '. Basically, I don't think I get what I'm making response equal to, is
>> >> it an empty string, or?
>> >
>> > != and == are tests and not assignments.  If you exchange == for !=
>> > you also need to exchange branches of the if else end construct.
>>
>> So basically with != and == I'm asking if what precedes the expression
>> is either "different from"  or "the same as" whatever follows. Am I
>> correct?
>>
>
> That would be correct.
>

Great!

>
>> Also, I still don't think I fully understand the empty string. In the
>> two lines of code...
>>
>> if response != ''
>> responses.push response
>>
>> ...am I doing something like "Is what was entered for the variable
>> response different from an empty string? If so then push whatever string
>> is entered to the end of the responses array."
>>
>
> That would also be correct. One other small item, normally code is
> indented
> (Ruby standard is 2 spaces) another level inside a control statement
> (if/while/else and such) to make it slightly easier to read the code.

I've been trying to do this as well as line up certain elements of code, 
but keep slipping in my enthusiasm to get it all out there. Def. need to 
try harder to keep it up. What about using Tab to indent, is there  any 
reason that might be frowned upon? Btw, I'm using TextMate.

>
> Taking your earlier work
>
> if response != ''
>   responses.push response
> else
>   puts responses.sort
>   break
> end
>
>
> It seemed to me that the logical way to enter this code would be
>>
>> responses = []
>> response = gets.chomp
>>
>> while response != ''
>>   responses.push response
>> end
>>
>> puts responses.sort
>>
>
> Actually very close here. Your problem is that you end up in an endless
> loop because you never get another entry from the user.
>
> This should do the trick
>
> responses = []
> response = gets.chomp
>
> while response != ''
>   responses.push response
>   response = gets.chomp # get another line from the user
> end
>
> puts responses.sort
>

Oh wow, ok, I think I get it. This is super clean too. Much nicer than 
what I originally had. Now, one last question, I need response = 
gets.chomp in the first instance just to define what the variable stands 
for, correct? It's not actually until the second instance where I'm 
soliciting input from the user, or actually is it more so the first 
instance both defines the variable and solicits  input from the user 
while the second instance solicits input in a continuous loop until it 
gets broken, i.e. when a user enters an empty string?

> But very very close for someone just picking up programming. You appear
> to
> at least grasp the basic mechanics of working through a problem!
>
> Best of luck to you!
>
> John

Thanks again John, super helpful! Almost done with chapter 9, "Writing 
Your Own Methods". Only 100 pages to go!

On another note, do you have any recommendations for Ruby resources 
and/or a path to take towards Ruby On Rails? I'm planning on finishing 
Learning to Program, doing the  Rails for Zombies courses, then diving 
into Michael Hartl's tutorial for Rails 2.3 and then reading Agile 
Development with Rails 3rd edition. Thoughts? Btw, I'm learning 2.3 as a 
site I had built was in 2.3.8 and I figure I should learn that first and 
then later learn 3 / 3.1.

Thanks,

Emeka

-- 
Posted via http://www.ruby-forum.com/.

In This Thread