loading...

re: Which is more readable? VIEW POST

TOP OF THREAD FULL DISCUSSION
re: This could be a job for a template language like erb, but that might be overkill if the rest of the json data isn't very complicated. I like the s...
 

I prefer this solution as well. It's simple and clear. Easy to understand.

json_data = {
  user: add_user_data(mentioner)
}

if mentionable_type == "Comment"
  json_data[:comment] = add_comment_data(mentionable) 
end
 

My preference goes with this one as well. Declaring json_data = {} in advanced just isn't necessary for writing code that is easy to be able to follow along with.

Code of Conduct Report abuse