0

Why doesn't this work?

I have an array of Objects, one of the attributes is the db id. I can make the array like so.

qc_parts.map!{|a| a.id}

However when I want to just make it a string. With

qc_parts.map!{|a| a.id}.join(",")

I only get an array out. I've also tried .to_s & .to_a Any idea why this would be happening?

0

1 Answer 1

2

qc_parts.map!{|a| a.id}.join(",") will return a string, but it will not to put that value into the variable qc_parts. To do that you have to do

qc_parts = qc_parts.map{|a| a.id}.join(",")

If I've misunderstood, and you actually are seeing the join method return an array, then something strange is going on.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.