Skip to main content
13 events
when toggle format what by license comment
Aug 30, 2017 at 14:35 comment added Carl Woll You could use the form OptionValue[defaults, ad, {"accept_rate", "age", "badge_counts" -> "bronze", "badge_counts" -> "gold"}] instead. It will complain that defaults is missing a rule for "accept_rate", but that is easy to fix.
Apr 13, 2017 at 12:55 history edited CommunityBot
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Jul 18, 2015 at 9:54 history edited Mr.Wizard CC BY-SA 3.0
deleted 2 characters in body
Jul 18, 2015 at 9:48 history edited Mr.Wizard CC BY-SA 3.0
added 1029 characters in body
Jul 18, 2015 at 8:36 comment added Athanassios @Mr.Wizard your solution is great but it seems to me default values work only for non-nested values. I have tested this by creating another set where "badge_counts"->"gold" value is missing and I am getting an error message Option name badge_counts ->gold not found in defaults for \ {{display_name ->Stones ,accept_rate ->80,account_id \ ->495497,badge_counts ->{bronze ->39,silver ->9}},{age \ ->Missing[],badge_counts ->{bronze ->Missing[NotAvailable ],gold \ ->Missing[NotAvailable ],silver ->Missing[NotAvailable ]}}}. >>
Mar 17, 2012 at 22:42 comment added rcollyer Not that I am aware of.
Mar 17, 2012 at 22:22 comment added Mr.Wizard @rcollyer sorry, I wasn't clear; can you set a default value that applies to all options (without having to list all of them), even for a symbol?
Mar 17, 2012 at 18:05 comment added rcollyer Exactly, the problem. SetOptions requires a symbol to be associated with the options. In this case, it isn't clear what symbol you'd use.
Mar 17, 2012 at 17:07 comment added Mr.Wizard @rcollyer how would you do it via SetOptions?
Mar 17, 2012 at 17:02 comment added rcollyer The only way I'm a aware of is via SetOptions which isn't exactly what you want.
Mar 17, 2012 at 13:19 comment added Mr.Wizard @rcollyer is there any way to set a default value for any missing option? That would make this more elegant. Nevertheless I think this is the best way to deal with nested rules; getting a value for e.g. a -> b -> c -> d is pretty hairy otherwise.
Mar 17, 2012 at 13:13 comment added rcollyer +1, I hadn't thought of OptionValue.
Mar 17, 2012 at 12:06 history answered Mr.Wizard CC BY-SA 3.0