[Solved] Can somenone translate this from Ruby to Python. Its a basic map function [closed]


So to answer your questions regarding operators like << or ||= []:

  • << appends an element to an array (or appends strings), in the case above it’s used to append the comment object to either the results array or or the threaded thingy.
  • ||= basically means, if left-hand-side is undefined then evaluate & assign right-hand-side ([] is the same as Array.new) => “if map[parent] is undefined, initialize it with Array.new – else do nothing”

To method above creates an array with parent comments (results) and a hash with child comments (map).

solved Can somenone translate this from Ruby to Python. Its a basic map function [closed]