Map on empty array

Does anyone know what happens when you attempt to use the map filter on an array that’s empty? Say, for example, that you attempt:

site.pages | map: “path”

But site,pages doesn’t contain any pages. Will map return an empty array? Will it return false, or nil?

Why not try it and see? If you add the inspect filter it should tell you.

{{ site.pages | map: “path” | inspect }}

That’s awesome. I had no idea that existed. Thanks.

Also, for things like this, Ruby’s irb (interactive shell, aka ‘REPL’) is great. You can start it by typing irb at the command line, then just run any Ruby command:

➜  ~   irb
2.5.3 :001 > [].map { |x| x.to_s }
 => []

Thanks, I’ll give that a shot as well. Does IRB recognize all of Liquid’s filters?