Using <array>.pluck()

Can anyone give me an example of how to properly use the .pluck() method in Twine? Every time I try it, it either spits it out as text rather than executing the function or just shows me a blank spot where it should be. For example

<<set $dogs = ["lab",  "golden", "chihuahua", "staffordshire"]>>

My favorite kind of dog is $dogs.pluck()

doesn’t give me anything. Any thoughts? Or is there a better tool?

The naked variable markup only works for variables or array or property accesses ($dogs or $dogs[3] or $dogs.length). If you want to call a function (like pluck) you’ll need to use one of the print macros (<<print $dogs.pluck()>> or <<= $dogs.pluck()>>).

1 Like

Thank you! I ended up simplifying my program to avoid it anyway, but this will come in handy later.