Sophrinix / TryRuby

Try Ruby is a interactive shell that quickly and whimsically teaches the Ruby programming language. Originally _why's idea, it has been recreated from the ground up by Rubyists who have a passion for Ruby and for teaching their fellow (wo)man how to program.
tryruby.org
345 stars 80 forks source link

to_a method #23

Closed leizzer closed 14 years ago

leizzer commented 14 years ago

im trying the 1.9 version, and the to_a method throw an error, i think it is obsolete in 1.9

leizzer commented 14 years ago

More spesific, in "help 1": But you can always convert between different types using Ruby's "to" methods.

* to_s converts things to strings.
* to_i converts things to integers (numbers.)
* to_a converts things to arrays.
Sophrinix commented 14 years ago

check out: http://blog.grayproductions.net/articles/getting_code_ready_for_ruby_19

It isn't so much deprecated as it has evolved :-)

whereas before you may have (or haven't before )typed

reddit = "I Haz Narwhal".to_a

Now it's: reddit = "I Haz Narwhal".reddit.to_a

This seems odd that they would go backwards.

However, when I tried this just now in tryruby, it failed to return anything.

So, it turns out that this really is a bug (for to_a) at least. to_s works and to_i appears to work.

I'll look into this later today. Thanks for the bug report.

Sophrinix commented 14 years ago

I stand hugely corrected. to_a by default is no longer there for a string!

see: http://dablog.rubypal.com/2009/1/16/son-of-10-things-to-be-aware-of-in-ruby-1-9

Sophrinix commented 14 years ago

Does anyone know of any authoritative 1.9 change log other than the one straight from matz?

It might be worth the time to have a off to the side widget or maybe a built in function that will alert you of depreciated syntax.

I'm leaving this ticket open for the purpose of discussion.

ghost commented 14 years ago

Is this "straight from matz"? http://svn.ruby-lang.org/repos/ruby/trunk/NEWS or http://svn.ruby-lang.org/repos/ruby/trunk/ChangeLog

Sophrinix commented 14 years ago

this is a good resource, but it needs to be more accessible. I'll get around to it if i can ever get the time to finish stabilizing this project first.

I still intended to eventually extend out a R bridge and have the popup module be useful as a graph calculator output.

Also, new lessons would be nice. Some ideas for lessons include using rspec or cucumber.

These are all things on my agenda that I plan on implementing.

Hopefully things will slow down for me in the next month or so.

ghost commented 14 years ago

For strings, you can use String#split.

This issue should be no longer an issue.

Sophrinix commented 14 years ago

This infact does not appear to be an issue closing. I have done a radical amount of re factoring on the "rails" branch. Any remaining issue will be tagged as still being an issue in the rails branch.