Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Switch with refinements/hmmm!

From: joel:neely:fedex at: 31-Oct-2001 17:10

Hi, Tim, Tim Johnson wrote:
> refine-switch: func[ /ref-one /ref-two /ref-three][ > switch <duh>what would I put her</duh>[ ; needs a value > ref-one[print "ref-one"] > ref-two[print "ref-two"] > ref-three[print "ref-three"] > ] > ] >
If you expect at most one refinement to be used refine-switch: func [ /refa /refb /refc ] [ either refa [ print "ref A" ][either refb [ print "ref B" ][either refc [ print "ref C" ][ print "NO ref" ]]] ] If more than one can be present (which, of course, REBOL syntax allows to occur) refine-switch: func [/refa /refb /refc][ either any [refa refb refc] [ if refa [print "ref A"] if refb [print "ref B"] if refc [print "ref C"] ][ print "NO ref" ] exit ] (or several variations!) I know I didn't answer exactly the way the question was worded, but I'm not sure that SWITCH is the most obvious solution. Sterling's reply was ingeneous (and I've certainly done such things myself ;-) but it's not likely to be immediately clear to the casual reader what's going on . HTH! -jn- -- This sentence contradicts itself -- no actually it doesn't. -- Doug Hofstadter joel<dot>neely<at>fedex<dot>com