跳轉到內容

Rebol 程式設計/switch

來自華夏公益教科書,開放的書籍,用於開放的世界
SWITCH value cases /default case /all 

選擇一個選項並評估其後的塊。

SWITCH 是一個原生值。

  • -- 要搜尋的值。 (型別:任何)
  • 情況 -- 要搜尋的案例塊。 (型別:塊)
  • /預設
    • 情況 -- 如果沒有找到其他情況,則為預設情況。 (型別:任何)
  • /all -- 評估所有匹配項(不僅僅是第一個)。

原始碼

[編輯 | 編輯原始碼]
switch: native[
    {Selects a choice and evaluates the block that follows it.} 
    value "Value to search for." 
    cases [block!] "Block of cases to search." 
    /default case "Default case if no others are found." 
    /all "Evaluates all matches (not just first one)."
]
華夏公益教科書