How to return more than one value from a function?

Hi

  In an action in admin_controller, I called a method in the model ci.rb
  The code is shown below:

   In controller:
       can_delete = Ci.is_ci_class_in_use(ci_type, @ci_classes)

   Then in model:

     class Ci < ActiveRecord::Base

       def self.is_ci_class_in_use(ci_type,ci_classes)
         @cis=self.find_all_by_citype(ci_type.to_s)
         for ci in @cis
           for ci_class in ci_classes
             if ci.content.ci_class.to_i == ci_class.id.to_i
               can_delete = 0
               ci_number = ci.ci_number
               break
             else
               can_delete = 1
             end
           break if can_delete==0
          end
          break if can_delete==0
         end
        return # I have to return two variables can_delete and
ci_number here.
       end
     end

     How can I return the two variables can_delete and ci_number?
     Please help.

Thanks
Regards
Suneeta

Unnikrishnan Kp wrote:

Why dont you return it as an Array? - return [can_delete,ci_number]

On Jun 24, 11:09 am, Suneeta Km <rails-mailing-l...@andreas-s.net>

Hi

Thank you for your help. I tried returning it as an array. Then I
printed it in the console to see how it is returned.

  can_delete = Ci.is_ci_class_in_use(ci_type, @ci_classes)
  puts "the value returned is: " +can_delete.to_s

It printed:
  the value returned is: 0CI15

  The value of can_delete = 0 and ci_number = CI15

How can I retrieve these values from the returned array?

Thanks
Suneeta

return as hash or array
return {:can_delete => 0, :ci_number => what_ever_the_number}

-pandian

thank you.. it works. I returned it as an array

Suneeta Km wrote:

thank you.. it works. I returned it as an array

You can also just use more than one variable on the receiving end and
send each value back independently (not in an array).

var_1, var_2 = some_method

def some_method
    return 'hi', 'there'
end

Peace,
Phillip