What is the Ruby way to achieve following?
a = [1,2]
b = [3,4]
I want an array:
=> [f(1,3) ,f(1,4) , f(2,3) ,f(2,4)]
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use
productto get the cartesian product of the arrays first, then collect the function results.So you can use
maporcollectto get the results. They are different names for the same method.