bartavelle / language-puppet

A library to work with Puppet manifests, test them and eventually replace everything ruby.
BSD 3-Clause "New" or "Revised" License
51 stars 8 forks source link

stdlib :: pick_default #157

Closed jfroche closed 8 years ago

jfroche commented 8 years ago

Would it be possible to implement the pick_default. Shouldn't be really different than the pick(). Just avoid to throw an exception

pick_default :: [PValue] -> InterpreterMonad PValue
pick_default (a:as)
    | a `elem` [PUndef, PString "", PString "undef"] = pick as
    | otherwise = return a

original code: https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/lib/puppet/parser/functions/pick_default.rb

jfroche commented 8 years ago

Works for me. Thank you !