daily pastebin goal
1%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Ruby passing lots of args
  2. def my_method(arg1, arg2, ..., arg20)
  3.   #do some stuff
  4.   my_second_method(arg1, arg2, ..., arg20)
  5.   #do other stuff
  6. end
  7.    
  8. def my_method(arg1, arg2, ..., arg20)
  9.   #do some stuff
  10.   my_second_method(args[array])
  11.   #do other stuff
  12. end
  13.    
  14. def one(*args)
  15.     # process/validate args
  16.     two(*args)     # Note that the splat is needed here too.
  17.   end
  18.  
  19.   def two(*args)
  20.     # do work
  21.   end
  22.    
  23. def my_method(*args)
  24.     # do some stuff
  25.     my_second_method(*args)
  26.     # do other stuff
  27. end
  28.  
  29. def my_second_method(*args)
  30.     # use args[0] through args[19]
  31. end
  32.    
  33. render :partial => "new", :locals => {:object => @my_object}
  34.    
  35. def as_array(*args)
  36.   if args.length == 3
  37.     a, b, c = args
  38.     puts "a=#{a} b=#{b} c=#{c}"
  39.   end
  40. end
  41.  
  42.  
  43. as_array 1, 2, 3
  44.    
  45. def method1(*args)
  46.   method2(*args)
  47. end
  48.  
  49. def method2(*args)
  50. end
  51.  
  52. method1(a, b, c, d, e, f, g)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top