From: Hugh Sasse Staff Elec Eng Date: 2000-10-17T02:45:13+09:00 Subject: [ruby-talk:5600] passing single or multiple strings. With multple assignments I can get nested arrays "shelled" (like peas) until there is one outermost container: irb(main):008:0> *x = [1, 2], 3 [[1, 2], 3] irb(main):009:0> x [[1, 2], 3] irb(main):010:0> *y = [1,2] [1, 2] irb(main):011:0> y [1, 2] So I can do def something(args) *bunch_of_args = args bunch_of_args.each do ... end end That's fine, and quite useful; if args are Strings and I just get one string then I don't get caught out by wanting to write: case args.type when Array ... when String ... end which does not work. (You have to use if args.type == Array...elsif.... for that.) But this is quite different: def something(*bunch_of_args) bunch_of_args.each do ... end end because then things are not "shelled" out and if I pass in an Array I get a nested Array. something(["x", "y"]) => bunch_of_args == [["x", "y"]] So what method of Array, if any, will do this "shelling" for me? It is not flatten, that is quite different. Hugh hgs@dmu.ac.uk