[#306796] Hash#select returns an array but Hash#reject returns a hash... — "Srijayanth Sridhar" <srijayanth@...>

Hello,

21 messages 2008/07/01
[#306820] Re: Hash#select returns an array but Hash#reject returns a hash... — Dave Bass <davebass@...> 2008/07/01

Srijayanth Sridhar wrote:

[#306822] Re: Hash#select returns an array but Hash#reject returns a hash... — "Srijayanth Sridhar" <srijayanth@...> 2008/07/01

irb(main):001:0> a=Hash.new

[#306825] Re: Hash#select returns an array but Hash#reject returns a hash... — Pe, Botp <botp@...> 2008/07/01

From: Srijayanth Sridhar [mailto:srijayanth@gmail.com]=20

[#306835] Re: Hash#select returns an array but Hash#reject returns a hash... — "Srijayanth Sridhar" <srijayanth@...> 2008/07/01

>

[#306838] Re: Hash#select returns an array but Hash#reject returns a hash... — "David A. Black" <dblack@...> 2008/07/01

Hi --

[#306849] Re: Hash#select returns an array but Hash#reject returns a hash... — "Rick DeNatale" <rick.denatale@...> 2008/07/01

On Tue, Jul 1, 2008 at 8:48 AM, David A. Black <dblack@rubypal.com> wrote:

[#306809] Dynamic Variables — Marc Heiler <shevegen@...>

Is there any way in ruby to create dynamic variables?

13 messages 2008/07/01

[#306908] threadify-0.0.1 — ara howard <ara.t.howard@...>

19 messages 2008/07/01

[#306924] workarounds for ruby 1.8.6 segmentations faults — liquid_rails <cheri.anaclerio@...>

Hi,

12 messages 2008/07/01

[#307014] Ranges and Enumerable problems — "Glen Holcomb" <damnbigman@...>

Okay so when I play with "!".."~" wrong things happen.

24 messages 2008/07/02
[#307018] Re: Ranges and Enumerable problems — "Robert Klemme" <shortcutter@...> 2008/07/02

2008/7/2 Glen Holcomb <damnbigman@gmail.com>:

[#307021] Re: Ranges and Enumerable problems — "Glen Holcomb" <damnbigman@...> 2008/07/02

On Wed, Jul 2, 2008 at 9:12 AM, Robert Klemme <shortcutter@googlemail.com>

[#307030] Re: Ranges and Enumerable problems — "Adam Shelly" <adam.shelly@...> 2008/07/02

On 7/2/08, Glen Holcomb <damnbigman@gmail.com> wrote:

[#307035] Re: Ranges and Enumerable problems — "Robert Dober" <robert.dober@...> 2008/07/02

On Wed, Jul 2, 2008 at 7:13 PM, Adam Shelly <adam.shelly@gmail.com> wrote:

[#307037] Re: Ranges and Enumerable problems — "Adam Shelly" <adam.shelly@...> 2008/07/02

On 7/2/08, Robert Dober <robert.dober@gmail.com> wrote:

[#307042] Re: Ranges and Enumerable problems — Robert Klemme <shortcutter@...> 2008/07/02

On 02.07.2008 19:48, Adam Shelly wrote:

[#307050] Re: Ranges and Enumerable problems — "Rick DeNatale" <rick.denatale@...> 2008/07/02

On Wed, Jul 2, 2008 at 2:27 PM, Robert Klemme <shortcutter@googlemail.com>

[#307053] Re: Ranges and Enumerable problems — "Todd Benson" <caduceass@...> 2008/07/02

On Wed, Jul 2, 2008 at 3:50 PM, Rick DeNatale <rick.denatale@gmail.com> wrote:

[#307070] Install/Enable openssl for ruby 1.8.6? — Jason Bornhoft <jbornhoft@...>

I was trying to install Redmine on rails 2.0.2 (this is not a rails

12 messages 2008/07/03

[#307080] thoughts on a more generic Array#partition function — "Rudi Cilibrasi" <cilibrar@...>

An experiment in a more generic partition function. The current

16 messages 2008/07/03
[#307083] Re: thoughts on a more generic Array#partition function — Pe, Botp <botp@...> 2008/07/03

From: Rudi Cilibrasi [mailto:cilibrar@gmail.com]=20

[#307088] Re: thoughts on a more generic Array#partition function — "Rudi Cilibrasi" <cilibrar@...> 2008/07/03

Hi Botp,

[#307095] Re: thoughts on a more generic Array#partition function — Pe, Botp <botp@...> 2008/07/03

From: Rudi Cilibrasi [mailto:cilibrar@gmail.com]=20

[#307136] Re: thoughts on a more generic Array#partition function — "Rick DeNatale" <rick.denatale@...> 2008/07/03

On Thu, Jul 3, 2008 at 12:53 AM, Pe=F1a, Botp <botp@delmonte-phil.com> wrot=

[#307101] Slide Show (S9) Gem Now Includes S5 Support (Including Built-In Gradient Themes) — "Gerald Bauer" <geraldbauer2007@...>

Hello,

21 messages 2008/07/03

[#307153] pseudo-randomize an array in a consistent order — Max Williams <toastkid.williams@...>

Does anyone know how to pseudo-randomize an array (eg with a seed) so

24 messages 2008/07/03

[#307246] Getting Folder Size — Clement Ow <clement.ow@...>

When I use File.size("C:/ruby"), all it returns is 0.

15 messages 2008/07/04

[#307284] from ruby/RoR to Java (framework unknown) :( — S2 <x@...>

My company today decided to ditch ruby development and to develop new web

35 messages 2008/07/04

[#307302] Does Ruby have any advantage over Python to create semantic applications? — Costan <CMValma@...>

Hi all,

10 messages 2008/07/04

[#307414] implementing a simple and efficient index system — Janus Bor <janus@...>

Hello everyone,

18 messages 2008/07/06
[#307415] Re: implementing a simple and efficient index system — phlip <phlip2005@...> 2008/07/06

Janus Bor wrote:

[#307585] Threads: Different behavior under Linux and Windows — Armin Armbruster <aarmbruster@...>

Hi,

13 messages 2008/07/08

[#307654] How to delete a file in Win XP — MAwiniarski <MAwiniarski@...>

Greetings,

18 messages 2008/07/09

[#307667] Thread-safe priority queue? — "Sean O'Halpin" <sean.ohalpin@...>

Hi,

13 messages 2008/07/09

[#307804] Why Ruby interpreter is writed in c (not in c++)? — "Ranieri Teixeira" <ranieri.tx@...>

Hi,

27 messages 2008/07/11
[#307807] Re: Why Ruby interpreter is writed in c (not in c++)? — phlip <phlip2005@...> 2008/07/11

Ranieri Teixeira wrote:

[#307853] Symbolify (#169) — "Matthew Moss" <matthew.moss@...>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

78 messages 2008/07/11
[#307863] Re: [QUIZ] Symbolify (#169) — "ara.t.howard" <ara.t.howard@...> 2008/07/11

[#307870] Re: [QUIZ] Symbolify (#169) — "Alex LeDonne" <aledonne.listmail@...> 2008/07/11

On Fri, Jul 11, 2008 at 12:12 PM, ara.t.howard <ara.t.howard@gmail.com> wrote:

[#307874] Re: [QUIZ] Symbolify (#169) — "ara.t.howard" <ara.t.howard@...> 2008/07/11

[#307879] Re: [QUIZ] Symbolify (#169) — Dana Merrick <dmerrick@...> 2008/07/11

ara.t.howard wrote:

[#307882] Re: [QUIZ] Symbolify (#169) — "ara.t.howard" <ara.t.howard@...> 2008/07/11

[#307883] Re: [QUIZ] Symbolify (#169) — James Gray <james@...> 2008/07/11

On Jul 11, 2008, at 12:16 PM, ara.t.howard wrote:

[#307933] can ruby replace bash scripts for linux script — "Greg Hauptmann" <greg.hauptmann.ruby@...>

hi,

14 messages 2008/07/12

[#307962] Can't install gems after a new ubuntu install — Max Williams <toastkid.williams@...>

Sorry if this is the wrong forum...

15 messages 2008/07/12

[#307973] regular expressions help — Vivek <krishna.vivek@...>

Hi,

17 messages 2008/07/12

[#308154] Text Editor — Jacob Grover <jacob.grover@...>

Hello, I've been wondering for a long time if there's an Internet text

14 messages 2008/07/14

[#308240] Is it possible to dynamically extend Test::Unit test cases? — "David Mitchell" <monch1962@...>

Hello list,

10 messages 2008/07/15

[#308264] Array.drop doesn't work — Li Chen <chen_li3@...>

Hi all,

14 messages 2008/07/15
[#308265] Re: Array.drop doesn't work — Frederick Cheung <frederick.cheung@...> 2008/07/15

[#308370] The next number that is not in an array — Tim Conner <crofty_james@...>

I want to increment the current value of a variable to the next number

28 messages 2008/07/16
[#308381] Re: The next number that is not in an array — "David A. Black" <dblack@...> 2008/07/16

Hi --

[#308409] So who's coming to RubyFringe? — Oliver Saunders <oliver.saunders@...>

...I am! Hope you meet some of you guys over here.

11 messages 2008/07/17

[#308509] Records and Arrays (#170) — "Matthew Moss" <matthew.moss@...>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

13 messages 2008/07/18

[#308525] Multiple GEM repositories — Rob Mauchel <rmauchel@...>

I have a Ruby script which runs fine on my own machine that I'd like to

14 messages 2008/07/18

[#308642] Does "rescue" wihtour argument handle any kind of Exception or not? — Iñaki Baz Castillo <ibc@...>

Hi, I read in this article:

17 messages 2008/07/20
[#308643] Re: Does "rescue" wihtour argument handle any kind of Exception or not? — Stefano Crocco <stefano.crocco@...> 2008/07/20

On Sunday 20 July 2008, I=C3=B1aki Baz Castillo wrote:

[#308645] Re: Does "rescue" wihtour argument handle any kind of Exception or not? — Phlip <phlip2005@...> 2008/07/20

Stefano Crocco wrote:

[#308698] rdoc 2.1.0 Released — Eric Hodel <drbrain@...7.net>

rdoc version 2.1.0 has been released!

25 messages 2008/07/21
[#308723] Re: [ANN] rdoc 2.1.0 Released — Joel VanderWerf <vjoel@...> 2008/07/21

Eric Hodel wrote:

[#308750] Re: [ANN] rdoc 2.1.0 Released — Marcin Raczkowski <mailing.mr@...> 2008/07/21

I started playing with new release and frameless template doesn't work.

[#308759] Re: [ANN] rdoc 2.1.0 Released — Eric Hodel <drbrain@...7.net> 2008/07/22

On Jul 21, 2008, at 14:05 PM, Marcin Raczkowski wrote:

[#308790] Re: [ANN] rdoc 2.1.0 Released — Marcin Raczkowski <mailing.mr@...> 2008/07/22

Eric Hodel wrote:

[#308853] Re: [ANN] rdoc 2.1.0 Released — Eric Hodel <drbrain@...7.net> 2008/07/22

[#308699] protected members or explicit abstract classes? — aidy <aidy.lewis@...>

Hi,

12 messages 2008/07/21

[#308736] read CSV file using csv library — Li Chen <chen_li3@...>

Hi all,

19 messages 2008/07/21
[#308774] Re: read CSV file using csv library — "kranthi reddy" <kranthicu@...> 2008/07/22

Hey you can use faster csv instead using the standard csv ruby library.

[#308817] Re: read CSV file using csv library — Li Chen <chen_li3@...> 2008/07/22

kranthi reddy wrote:

[#308821] Re: read CSV file using csv library — "kranthi reddy" <kranthicu@...> 2008/07/22

Hi,

[#347910] Re: read CSV file using csv library — Frank Guerino <frank.guerino@...> 2009/10/07

kranthi reddy wrote:

[#347914] Re: read CSV file using csv library — Marvin Gülker <sutniuq@...> 2009/10/07

Frank Guerino wrote:

[#308761] bj and rails 2.1 - can't get bj to run jobs — dusty <dusty.doris@...>

I have been trying to setup bj with rails 2.1.0 and am having some

13 messages 2008/07/22

[#308831] simple module for "count my instances" behaviour — Julien Thewys <jt@...>

I want to make a simple module that makes its including classes

11 messages 2008/07/22

[#308847] how to capitalize a number of characters in a word — Cheyne Li <happy.go.lucky.clr@...>

Hi, there

13 messages 2008/07/22

[#308884] Is there a simple way to find a method definition? — Ruby Freak <twscannell@...>

Hi,

12 messages 2008/07/23

[#308909] circular 'require' — Shadowfirebird <shadowfirebird@...>

Hi,

29 messages 2008/07/23
[#308911] Re: circular 'require' — Stefano Crocco <stefano.crocco@...> 2008/07/23

On Wednesday 23 July 2008, Shadowfirebird wrote:

[#308919] Re: circular 'require' — Calamitas <calamitates@...> 2008/07/23

On Wed, Jul 23, 2008 at 12:18 PM, Stefano Crocco

[#308935] Re: circular 'require' — "Michael T. Richter" <ttmrichter@...> 2008/07/23

On Wed, 2008-07-23 at 20:39 +0900, Calamitas wrote:

[#308940] Re: circular 'require' — Shadowfirebird <shadowfirebird@...> 2008/07/23

I found a very easy way around it. This is what bothers me. If it's

[#308943] Re: circular 'require' — "Michael T. Richter" <ttmrichter@...> 2008/07/23

On Wed, 2008-07-23 at 22:48 +0900, Shadowfirebird wrote:

[#308944] Re: circular 'require' — Shadowfirebird <shadowfirebird@...> 2008/07/23

Yes, I can see now that in your example no order of loading will allow

[#308951] Of GUIs threads and scheduling woes — "Glen Holcomb" <damnbigman@...>

I have a small GUI app that I have written the purposes for it's creation

12 messages 2008/07/23

[#309006] differnce between .nil? , .empty?, .blank? — Sijo Kg <sijo@...>

Hi

11 messages 2008/07/24

[#309074] Simultaneously URL call, is it possible? — Toki Toki <toki84@...>

Hi to all!

22 messages 2008/07/24
[#309080] Re: Simultaneously URL call, is it possible? — matu <m@...> 2008/07/24

Toki Toki wrote:

[#309083] Re: Simultaneously URL call, is it possible? — Toki Toki <toki84@...> 2008/07/24

matu wrote:

[#309089] inline comments in future release? — Mike Schwab <mike.schwab@...>

Are inline comments a potential feature of Ruby 2.0?

25 messages 2008/07/24
[#309101] Re: inline comments in future release? — Tim Hunter <TimHunter@...> 2008/07/24

Mike Schwab wrote:

[#309111] Re: inline comments in future release? — Mike Schwab <mike.schwab@...> 2008/07/25

> If you have so much code on one line that you feel the need for inline

[#309112] Re: inline comments in future release? — "Michael W. Ryder" <_mwryder@...> 2008/07/25

Mike Schwab wrote:

[#309113] Re: inline comments in future release? — Peña, Botp <botp@...> 2008/07/25

RnJvbTogTWljaGFlbCBXLiBSeWRlciBbbWFpbHRvOl9td3J5ZGVyQHdvcmxkbmV0LmF0dC5uZXRd

[#309165] weird backsplash behaviour inside single quotes — "Michal Suchanek" <hramrach@...>

Hello

13 messages 2008/07/25
[#309170] Re: weird backsplash behaviour inside single quotes — "Todd Benson" <caduceass@...> 2008/07/25

On Fri, Jul 25, 2008 at 8:34 AM, Michal Suchanek <hramrach@centrum.cz> wrote:

[#309171] Re: weird backsplash behaviour inside single quotes — "Todd Benson" <caduceass@...> 2008/07/25

On Fri, Jul 25, 2008 at 9:33 AM, Todd Benson <caduceass@gmail.com> wrote:

[#309173] Interesting Array Initialization Typo — Maciej Tomaka <lunatyq@...>

When initializing for example : [ [1, 2], [2, 3], [3, 2] ]

12 messages 2008/07/25

[#309194] hexdump (#171) — "Matthew Moss" <matthew.moss@...>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

13 messages 2008/07/25

[#309273] Faster Marshaling? — Greg Willits <lists@...>

Exploring options... wondering if there's anything that can replace

13 messages 2008/07/27

[#309278] deaf grandma. — Houston Barnett-gearhart <americanpragmatic@...>

i picked up ruby 2 days ago & have been bustlin' chris pine's "learn to

25 messages 2008/07/27
[#309282] Re: deaf grandma. — "Martin DeMello" <martindemello@...> 2008/07/27

On Sat, Jul 26, 2008 at 8:31 PM, Houston Barnett-gearhart

[#309322] Re: deaf grandma. — houston barnett-gearhart <americanpragmatic@...> 2008/07/27

thank you, martin, for your reply. i took your advice & wrote an

[#309341] Re: deaf grandma. — "Martin DeMello" <martindemello@...> 2008/07/28

On Sun, Jul 27, 2008 at 2:32 PM, houston barnett-gearhart

[#309343] Re: deaf grandma. — houston barnett-gearhart <americanpragmatic@...> 2008/07/28

Martin, is there any way I can get in touch with you outside of the

[#309391] Re: deaf grandma. — "Martin DeMello" <martindemello@...> 2008/07/28

On Sun, Jul 27, 2008 at 11:51 PM, houston barnett-gearhart

[#309407] Re: deaf grandma. — houston barnett-gearhart <americanpragmatic@...> 2008/07/28

I don't know why this is so hard for me to get my head around, but

[#309387] Win32ole equivalent for Mac OS X — Nathan Loyer <4namlet@...>

Is there an equivalent library for the Win32ole library on the PC? I

12 messages 2008/07/28

[#309441] Concurrent Ruby? — Kyle Murphy <kmurph79@...>

Apologies if this is a really stupid question, I am new to programming,

14 messages 2008/07/29

[#309442] and and or in case — Pe, Botp <botp@...>

Hi All, apologies in advanced if this has been discussed already

12 messages 2008/07/29

[#309472] libxml: is it possible not to use doctype declaration? — "ruud grosmann" <r.grosmann@...>

hi all,

17 messages 2008/07/29
[#309477] Re: libxml: is it possible not to use doctype declaration? — Phlip <phlip2005@...> 2008/07/29

ruud grosmann wrote:

[#309478] Re: libxml: is it possible not to use doctype declaration? — "ruud grosmann" <r.grosmann@...> 2008/07/29

hi Phlip,

[#309488] Re: libxml: is it possible not to use doctype declaration? — Phlip <phlip2005@...> 2008/07/29

ruud grosmann wrote:

[#309572] Re: How to do methodsoverloading in — Jeff Moore <jcmoore@...>

Sunny Bogawat wrote:

12 messages 2008/07/30

[#309589] Suggestions for improving a trivial tag parser — "Gregory Brown" <gregory.t.brown@...>

Hi folks,

11 messages 2008/07/30
[#309593] Re: Suggestions for improving a trivial tag parser — "Robert Dober" <robert.dober@...> 2008/07/30

What about

[#309627] gc doesn't collect? — Roger Pack <rogerpack2005@...>

Any ideas why:

13 messages 2008/07/31

[#309646] super with block — Lou Zell <lzell11@...>

Hi all,

17 messages 2008/07/31
[#309647] Re: super with block — "Jes俍 Gabriel y Gal疣" <jgabrielygalan@...> 2008/07/31

On Thu, Jul 31, 2008 at 11:06 AM, Lou Zell <lzell11@gmail.com> wrote:

[#309692] Re: super with block — Lou Zell <lzell11@...> 2008/07/31

> Hi,

[#309650] Help me with this Numerology code please... — Web Reservoir <webreservoir@...>

Hi,

18 messages 2008/07/31

[#309653] Cool Projects — Alasdair Bell <alasdair@...>

So, anyone working on something awesome?

31 messages 2008/07/31

[#309676] How to get special directories? — Niklas Baumstark <niklas.baumstark@...>

hi all,

18 messages 2008/07/31

[#309739] RubyGems - update made a mess - help needed with Windows — Becca Girl <cschall@...>

I just did a system update of RubyGems and it just broke my rake test. I

16 messages 2008/07/31

[ANN] NamedParameters v0.0.0 ('first', :second => 'release')

From: Roger Pack <rogerpack2005@...>
Date: 2008-07-18 04:54:20 UTC
List: ruby-talk #308476
NamedParameters
  is a library for (MRI) ruby 1.8.x that allows you to call a method
with or without named parameters.

Introduction

One thing that is notably lacking from Ruby is the ability to
arbitrarily call methods with named parameters.

Ex in this code:

class A
  def method_with_lots_of_parameters param1, p2, p3, p4 = 5, p6 = 7, p7
= 8, p9 = 900
    p7
  end
end
A.new.method_with_lots_of_parameters 1, 2, 3, 4, 5, 6, 7

can anybody guess what p7 will be when you run this? (a contrived
example, but an example nonetheless).

Previous attempts to overcome this have dealt with using a hash for the
ending argument, and/or *args for parameters. These are somewhat tedious
and also a little error prone, as misspellations aren't immediately
caught at run-time in the hash example, and parsing is annoying in the
*args example.

Enter named parameters.

With named parameters, you can define your method as you normally would,
and add one line:

class A
  def method_with_lots_of_parameters param1, p2, p3, p4 = 5, p6 = 7, p7
= 8, p9 = 900
    p7
  end
  # and add this line
  create_named_parameters_wrapper :method_with_lots_of_parameters
end

and now you can call it like

A.new.method_with_lots_of_parameters 1, 2, 3, 4, :p7 => 6

And it works as you'd expect.

How it works

It works by creating (in our example above) code equivalent to:

class A
  # save away the original function
  alias :_method_with_lots_of_parameters :method_with_lots_of_parameters

  def method_with_lots_of_parameters *args
     param1, p2, p3, p4, p6, p7, p9 = args.interpret [:param1, :p2,
:p3], :p4, :p6, :p7, :p9 # parses what you passed it, using the last
hash for named parameters
     if p4 == :__not_assigned
       p4 = 5
      end
     if p6 == :__not_assigned
       p6 = 7
     if p9 == :__not_assigned
        p9 = 900
     end
     _method_with_lots_of_parameters param1, p2, p3, p4, p6, p7, p9 #
call the original function
   end
end

Note also that class methods need to be called preceded by 'self.', like

class A
  def A.class_method1
  end
  create_named_parameters_wrapper :'self.class_method1'
end
[to satisfy parseTree's semantics.]

Also note that you must continue naming parameters once you start naming
them.
[i.e. method_with_lots_of_parameters :param1 => 2, 2, 3 is not allowed],
to help disambiguate which parameter is which [idea stolen from Python].

Many thanks to the parse tree and ruby2ruby crew for making this
possible.

In my own use of it I have seen increased code readability and
understandability, especially for methods that take more than a few
parameters.

Note also that if your current method takes an ending hash then this
won't work, as it uses the ending hash for named parameters.

How to install

sudo gem install ruby2ruby # pre requisite
svn co
http://ruby-roger-useful-functions.googlecode.com/svn/trunk/arg_parser/v2
named_args
require 'named_args/create_named_parameters_wrapper'
... # code as usual, adding create_named_parameters_wrapper calls to
functions you'd like to be able to have this functionality.

Feedback welcome.

This is just an early release as I wanted to publish in case it were
useful to anyone.

Take care.
=R
-- 
Posted via http://www.ruby-forum.com/.

In This Thread

Prev Next