wow, "the ruby way" may just have gotten ruby's equivalent of
help-me-make-my-program-more-"pythonic".
"deja-vu... a twitch in the matrix. It happens when they change
something."
hehe.
s.
wow, "the ruby way" may just have gotten ruby's equivalent of
help-me-make-my-program-more-"pythonic".
"deja-vu... a twitch in the matrix. It happens when they change
something."
hehe.
s.
Nah, iterating is where you step through the elements of an array. Your
examples are simply assignments--giving a value to a variable (think
basic algebra).
Methods are basically chunks of code split up so they can be reused in
other places. Also good for code maintenance--instead of having one huge
chunk of code, it is broken into smaller bits.
Do you actually have a need to write anything, or is it more of a "Hey
I'd like to learn this, it sounds interesting" thing? It sounds like
most of your prior forays into programming have been the latter. I find
that I learn (and more specifically RETAIN) much much better when I have
a direct need. I can't just grab a book and learn an arbitrary language
just for the hell of it. Something will eventually come up a few days
into it or whatever and I won't have a specific need to keep focused on it.
Scott
Will Shattuck wrote:
8. Arrays and Iterators
I touched on arrays in the "Head Start Java" book I was learning from,
but never got very far. Iterators are like " foo = foo +1" or " foo
+= foo " right?9. Writing Your Own Methods
Methods that are inside classes? Again another place I have a very
basic concept of, but haven't done much with.
- --
scott@lackluster.net
I concur. The table of contents seems to list the skills you need in the order
you need them. Looks like a good book, and from the sample chapter I read,
well written.
One more thing. Whenever I need to learn a new technology, here's the learning
method I use:
SteveT
On Monday 02 January 2006 02:31 am, J. Ryan Sobol wrote:
Seems like this book is a good match for you. And the price is right
too: $20 for a paper back, $13 for the PDF version, or $25 for both.Also, the "Pickaxe" book is pretty much the standard for learning
Ruby. I'm not sure if its at the appropriate level for you, but the
first edition is freely available online. http://www.rubycentral.com/
book/~ ryan ~
On Jan 2, 2006, at 1:47 AM, J. Ryan Sobol wrote:
> Sounds like your at the cusp of a new and exciting thing, so I want
> to give you the best advice I can.
>
> Here's the table of contents from the book "Learning To Program"
> that Ed Borasky suggested in a previous post. (http://
> www.pragmaticprogrammer.com/titles/fr_ltp/) Just by glancing at
> the chapter titles, which of them seem new, familiar, and old news
> to you in terms of your past programming experience?
>
> 1. Getting Started
> 2. Numbers
> 3. Letters
> 4. Variables and Assignment
> 5. Mixing It Up
> 6. More about Methods
> 7. Flow Control
> 8. Arrays and Iterators
> 9. Writing Your Own Methods
> 10. There's Nothing New to Learn in Chapter 10
> 11 Reading and Writing, Saving and Loading, Yin and...
> 12. New Classes of Objects
> 13. Creating New Classes, Changing Existing Ones
> 14. Blocks and Procs
>
> ~ ryan ~
>
> On Jan 2, 2006, at 1:30 AM, Will Shattuck wrote:
>> On 1/1/06, J. Ryan Sobol <ryansobol@gmail.com> wrote:
>>> Can you list and describe the programs you've developed in the past?
>>> Were they school related or side projects for fun or for profit?
>>>
>>> ~ ryan ~
>>
>> Well... that's just it. I haven't developed anything really. I have
>> done some web programming with PHP, but that has usually consisted of
>> modifying someone else's work. So basically nothingThat's why I
>> wanted to start with Ruby. I noticed that I can cut out many
>> lines of
>> code by using Ruby so I figured it would be a good start.
>>
>> Will
stijn wrote:
wow, "the ruby way" may just have gotten ruby's equivalent of
help-me-make-my-program-more-"pythonic".
In the sense of the programming language or in the sense of the famous
british comedy group?
"deja-vu... a twitch in the matrix. It happens when they change
something."
hehe.
s.
itch <= twitch - what does this tell us?
robert
To elaborate, I tend to suspect that the arrays and iterators chapter
discusses things like the each method -- that's what is meant by
"iterators" here. In particular, you could have an array called myarray
(for example) and iterate over its contents using the each method to
perform the same action on each element of the array:
myarray.each do { |foo| puts foo }
On Mon, Jan 02, 2006 at 04:29:14PM +0900, Scott Smith wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Nah, iterating is where you step through the elements of an array. Your
examples are simply assignments--giving a value to a variable (think
basic algebra).
--
Chad Perrin [ CCD CopyWrite | http://ccd.apotheon.org ]
This sig for rent: a Signify v1.14 production from http://www.debian.org/
Man y'all are amazing. I'll put my replies to everyone here.
Specific Project or Just Learning:
------------------------
I think it's a little of both. I always wanted to program from back
in the Apple Basic days. I just was always better with the
hardware/software troubleshooting stuff. In my day job I am a Lead
Help Desk Technician. At work I became good friends with the
programmers there and, since our network/server/sql admin left, I have
had to start learning MS SQL maintenance and some basic DBA Stuff.
As for a Project I want to create a Nethack bot. Like I said in my
intro a friend created a Nethack bot in C# and I wanted to see if I
could do it in Ruby. I have read a lot about Ruby in the last few
months, including Ruby on Rails, but I just do not know enough about
Ruby to do anything with it. I also have in mind to build a Wish List
web application for my family so we can know what everyone would like
for Christmas or for other occasions.
Iteration:
-------------
Thanks for reminding what Iteration is. As soon as you said it I
went, DUH!, heh. Arrays and Iteration is where I stopped in the "Head
Start Java" book. I think I stopped at a combination of frustration
and Real Life took over.
Books:
----------
All the high recommendations on books and websites are great. I will
begin to check them out. I have a birthday coming up so I may be able
to give some suggestions for my family when they want to buy me a
present
heh. But I'm old enough (married with a daughter) that I
can buy them myself too *chuckle*
Rapid Learning Flowchart:
------------------------
Wow this is cool. I think I do some of this on my own already. Not
as refined though. ![]()
I'll keep you all up-to-date with my progress. I'm sure you will get
more questions from me.
Thanks again for all the great informatoin and help.
WIll
On 1/2/06, Steve Litt <slitt@earthlink.net> wrote:
I concur. The table of contents seems to list the skills you need in the order
you need them. Looks like a good book, and from the sample chapter I read,
well written.One more thing. Whenever I need to learn a new technology, here's the learning
method I use:Rapid Learning: Secret Weapon of the Successful Technologist
SteveT
On Monday 02 January 2006 02:31 am, J. Ryan Sobol wrote:
> Seems like this book is a good match for you. And the price is right
> too: $20 for a paper back, $13 for the PDF version, or $25 for both.
>
> Also, the "Pickaxe" book is pretty much the standard for learning
> Ruby. I'm not sure if its at the appropriate level for you, but the
> first edition is freely available online. http://www.rubycentral.com/
> book/
>
> ~ ryan ~
>
> On Jan 2, 2006, at 1:47 AM, J. Ryan Sobol wrote:
> > Sounds like your at the cusp of a new and exciting thing, so I want
> > to give you the best advice I can.
> >
> > Here's the table of contents from the book "Learning To Program"
> > that Ed Borasky suggested in a previous post. (http://
> > www.pragmaticprogrammer.com/titles/fr_ltp/) Just by glancing at
> > the chapter titles, which of them seem new, familiar, and old news
> > to you in terms of your past programming experience?
> >
> > 1. Getting Started
> > 2. Numbers
> > 3. Letters
> > 4. Variables and Assignment
> > 5. Mixing It Up
> > 6. More about Methods
> > 7. Flow Control
> > 8. Arrays and Iterators
> > 9. Writing Your Own Methods
> > 10. There's Nothing New to Learn in Chapter 10
> > 11 Reading and Writing, Saving and Loading, Yin and...
> > 12. New Classes of Objects
> > 13. Creating New Classes, Changing Existing Ones
> > 14. Blocks and Procs
> >
> > ~ ryan ~
> >
> > On Jan 2, 2006, at 1:30 AM, Will Shattuck wrote:
> >> On 1/1/06, J. Ryan Sobol <ryansobol@gmail.com> wrote:
> >>> Can you list and describe the programs you've developed in the past?
> >>> Were they school related or side projects for fun or for profit?
> >>>
> >>> ~ ryan ~
> >>
> >> Well... that's just it. I haven't developed anything really. I have
> >> done some web programming with PHP, but that has usually consisted of
> >> modifying someone else's work. So basically nothingThat's why I
> >> wanted to start with Ruby. I noticed that I can cut out many
> >> lines of
> >> code by using Ruby so I figured it would be a good start.
> >>
> >> Will
--
Will Shattuck ( willshattuck.at.gmail.com )
Home Page: http://www.thewholeclan.com/will
When you get to your wit's end, you'll find God lives there.
Only we would never write that since the following does the same thing:
puts myarray
James Edward Gray II
On Jan 2, 2006, at 2:29 AM, Chad Perrin wrote:
In particular, you could have an array called myarray
(for example) and iterate over its contents using the each method to
perform the same action on each element of the array:myarray.each do { |foo| puts foo }
Well . . . true.
This is why I don't teach programming.
On Tue, Jan 03, 2006 at 12:03:03AM +0900, James Edward Gray II wrote:
On Jan 2, 2006, at 2:29 AM, Chad Perrin wrote:
>In particular, you could have an array called myarray
>(for example) and iterate over its contents using the each method to
>perform the same action on each element of the array:
>
> myarray.each do { |foo| puts foo }Only we would never write that since the following does the same thing:
puts myarray
--
Chad Perrin [ CCD CopyWrite | http://ccd.apotheon.org ]
"A script is what you give the actors. A program
is what you give the audience." - Larry Wall
Chad Perrin wrote:
On Tue, Jan 03, 2006 at 12:03:03AM +0900, James Edward Gray II wrote:
On Jan 2, 2006, at 2:29 AM, Chad Perrin wrote:
In particular, you could have an array called myarray
(for example) and iterate over its contents using the each method to
perform the same action on each element of the array:myarray.each do { |foo| puts foo }
Only we would never write that since the following does the same thing:
puts myarray
Well . . . true.
This is why I don't teach programming.
Actually, I think there's a difference in behavior
if you try them both.
Hal
Chad Perrin wrote:
In particular, you could have an array called myarray
(for example) and iterate over its contents using the each method to
perform the same action on each element of the array:myarray.each do { |foo| puts foo }
Only we would never write that since the following does the same thing:
puts myarray
Well . . . true.
This is why I don't teach programming.Actually, I think there's a difference in behavior
if you try them both.
Other than the return value?
>> (1..10).to_a.each { |n| puts n }
1
2
3
4
5
6
7
8
9
10
=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>> puts (1..10).to_a
1
2
3
4
5
6
7
8
9
10
=> nil
James Edward Gray II
On Jan 2, 2006, at 2:08 PM, Hal Fulton wrote:
On Tue, Jan 03, 2006 at 12:03:03AM +0900, James Edward Gray II wrote:
On Jan 2, 2006, at 2:29 AM, Chad Perrin wrote:
James Edward Gray II wrote:
On Jan 2, 2006, at 2:08 PM, Hal Fulton wrote:
Chad Perrin wrote:
On Tue, Jan 03, 2006 at 12:03:03AM +0900, James Edward Gray II wrote:
On Jan 2, 2006, at 2:29 AM, Chad Perrin wrote:
In particular, you could have an array called myarray
(for example) and iterate over its contents using the each method to
perform the same action on each element of the array:myarray.each do { |foo| puts foo }
Only we would never write that since the following does the same thing:
puts myarray
Well . . . true.
This is why I don't teach programming.Actually, I think there's a difference in behavior
if you try them both.Other than the return value?
Well, I'm quite wrong. I thought that 'puts myarray' would print
on a single line with elements scrunched together. Maybe this
was true in the past?
Of course, I *could* pretend I was talking about the extraneous
'do' in 'myarray.each do { |foo| puts foo }' ... but I wasm't. ![]()
Hal
Hal Fulton wrote:
Well, I'm quite wrong. I thought that 'puts myarray' would print
on a single line with elements scrunched together. Maybe this
was true in the past?
No... that's perl, iirc. ![]()
Of course, I *could* pretend I was talking about the extraneous
'do' in 'myarray.each do { |foo| puts foo }' ... but I wasm't.
wasm't?
Hi --
On Tue, 3 Jan 2006, Hal Fulton wrote:
James Edward Gray II wrote:
On Jan 2, 2006, at 2:08 PM, Hal Fulton wrote:
Chad Perrin wrote:
On Tue, Jan 03, 2006 at 12:03:03AM +0900, James Edward Gray II wrote:
On Jan 2, 2006, at 2:29 AM, Chad Perrin wrote:
In particular, you could have an array called myarray
(for example) and iterate over its contents using the each method to
perform the same action on each element of the array:myarray.each do { |foo| puts foo }
Only we would never write that since the following does the same thing:
puts myarray
Well . . . true.
This is why I don't teach programming.Actually, I think there's a difference in behavior
if you try them both.Other than the return value?
Well, I'm quite wrong. I thought that 'puts myarray' would print
on a single line with elements scrunched together. Maybe this
was true in the past?
I think what you're thinking of is array.to_s, which scrunches them
together. But puts array does a separate puts on each element.
David
--
David A. Black
dblack@wobblini.net
"Ruby for Rails", from Manning Publications, coming April 2006!
Hal Fulton wrote:
Well, I'm quite wrong. I thought that 'puts myarray' would print
on a single line with elements scrunched together. Maybe this
was true in the past?
Maybe. It certainly struck me as counter-intuitive. I would think it would print the results of myarry.to_s or myarry.to_str.
How (and why) did a call to an iterator get in there?
James
--
http://www.ruby-doc.org - Ruby Help & Documentation
Ruby Code & Style - Ruby Code & Style: Writers wanted
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
http://www.30secondrule.com - Building Better Tools
It's true for hashes.
2006/1/2, Devin Mullins <twifkak@comcast.net>:
Hal Fulton wrote:
> Well, I'm quite wrong. I thought that 'puts myarray' would print
> on a single line with elements scrunched together. Maybe this
> was true in the past?No... that's perl, iirc.
--
Gerardo Santana
Maybe he was thinking of "print myarray".
On Tue, Jan 03, 2006 at 06:22:56AM +0900, dblack@wobblini.net wrote:
On Tue, 3 Jan 2006, Hal Fulton wrote:
>
>Well, I'm quite wrong. I thought that 'puts myarray' would print
>on a single line with elements scrunched together. Maybe this
>was true in the past?I think what you're thinking of is array.to_s, which scrunches them
together. But puts array does a separate puts on each element.
--
Chad Perrin [ CCD CopyWrite | http://ccd.apotheon.org ]
"A script is what you give the actors. A program
is what you give the audience." - Larry Wall