From: Brian Candler Date: 2008-10-23T18:34:18+09:00 Subject: Re: What exactly does "rubyish" or "ruby way" mean? Nit Khair wrote: > Maybe the correct approach for me is to compare how a library is > implemented in another language (or non ruby way) versus a good ruby > implementation. e,g, > 1. compare getoptlong to optparse Ruby has both :-) That is, you will find both getoptlong.rb and optparse.rb in the standard library. The first tries to follow the C API, while the second tries to be more native-rubyish. However even optparse.rb is rather verbose to use, and there are other competitors in this space (e.g. commandline, trollop). You choose the one which suits you best. It just goes to show that even the ruby core language designers don't always have the deepest insights into "the best" API at the time when they first write one. More succinct and powerful APIs often develop through new insights from users of the older ones. I'd say you'll develop a sense for this over time. But don't worry about it too much. Even within the core library things aren't consistent. For example, some objects use capitalised symbols as option hash keys: WEBrick::HTTPServer.new(:BindAddress => "127.0.0.1", :Port => 1234) some use lower-case symbols with underscores: DRb.start_service("drb://127.0.0.1:1234", nil, :load_limit => 1_000_000) and some use strings: Net::Telnet.new("Host" => "1.2.3.4") You just have to learn the conventions for each library you use. -- Posted via http://www.ruby-forum.com/.