From: Zach Dennis Date: 2005-01-28T14:19:14+09:00 Subject: Re: Ten Things Every Java Programmer Should Know About Ruby Navindra Umanee wrote: > Zach Dennis wrote: > >> - you can use string interpolation, ex: "x: #{@myvar}" instead of >>having to say "x:" + myvar' > > > Ruby seems to lose here. The syntax #{@myvar} is a rare case of > ugliness. I don't know what the official ruling is, but when using variables you can drop the {}. @a = "here i go again" puts "#@a" @@a = ["here", " i", " go", " again" ] puts "#@@a" Also you have to way in heredoc support, which java dont got: a = "interpolation" b = "easier" c = "You know what I'm saying" str =<> - ruby doesn't force you to have 1 file per public class, you can have >>all the public classes you want in a file (not that you have to do this, >>but it's a nice option to have) > > > On the other hand, if you *want* to put each class in a file, you end > up having to painfully "require" each file every time you want to > access a class. Java can automatically find classes in the current > package and load them. Or is just me? Is there a Ruby Way? This totally depends on how you use your code. Most likely you won't need to access every file from it's src file. And if you do it is best to design a loader class: In main.rb you have: require "gui/gui" require "data/data" - gui/gui.rb which loads all required files for module GUI - data/data.rb which loads all required files for module DATA in gui.rb you have: require "layout" require "fonts" require "2dapi" require "3dapi" and similar in data/data.rb. You don't have to require each individual file you just have to design your program. I am not saying what you say wouldn't be nice, and someone may already have a modification to *require* for this to work, but you are not hindered right now in doing this, it just requires more discipline on the design and access of your code. And back to a java principle...alot java code are for one or two lines of code that use ((MyClass)getGenericObject()).setThis( true ); In Ruby you don't have to say "require myclass" just to do that. You just say: get_obj.this = true Zach