Returning value from ternary operator

Hi
I have

def get_company_details_array
c = nil
arr = [] if c.nil?
c.nil? ?  2.times {arr.push("")} :['a','b']

end
arr = [‘abc’] + get_company_details_array
puts arr.inspect

What I expected here is [“abc”,"",""] But I am getting error
array.rb:7:in `+’: can’t convert Fixnum into Array (TypeError)
from array.rb:7

     Could anybody please correct the code?

Thanks in advance
Sijo

2009/4/16 Sijo Kg [email protected]:

Hi
I have

def get_company_details_array
c = nil
arr = [] if c.nil?
c.nil? ? 2.times {arr.push(“”)} :[‘a’,‘b’]
end

What weird logic is that? Basically you can replace the method with

def get_company_details_array
[‘’,‘’]
end

arr = [‘abc’] + get_company_details_array
puts arr.inspect

What I expected here is [“abc”,“”,“”] But I am getting error
array.rb:7:in `+': can’t convert Fixnum into Array (TypeError)
from array.rb:7

    Could anybody please correct the code?

Hint: Fixnum#times returns the number.

Cheers

robert

No
it is not weird logic since I have omitted some portion for ease of
reading
complete code like

def get_company_details_array
c = self.onboarding_company
c.nil? ? ["","","",""] :[c.name,c.web_site_url,c.email,c.phone]
end