jeudi 5 juillet 2018

Can I directly append return function calls in Arrays?

I have a function that calls other functions that returns an object. I tried appending the return values of these functions using this format of code:

def get_cinfo(id)
  return Client.find(id)
end

def get_caddress(id)
  return Client.find(id).addresses
end

def get_cpolicies(id)
  return Client.find(id).policies
end

def get_ccontactinfo(id)
  return Client.find(id).contact_informations
end

def generate_client(id)
 client << get_cinfo(id) << get_caddress(id) << get_ccontactinfo(id)
end

where: get_cinfo , get_caddress and get_ccontactinfo are functions returning a single or two instance

The error produced: [get_cinfo...] variable is undefined.

Why is this happening? Are Function calls not directly allowed in appending to arrays?

Aucun commentaire:

Enregistrer un commentaire