2011-05-31 33 views
2

當我在KRL規則中編寫條件操作塊時,我總是忘記'then'關鍵字。這是正確的語法:爲什麼在KRL中需要關鍵字'then'

rule with_conditions { 
    select when pageview ".*" 
    pre { 
    cheese = "Camembert"; 
    } 
    if (cheese like re/bert/) then { 
    notify("Odd Cheese", "#{cheese} is unusual."); 
    } 
    fired { 
    raise explicit event "odd_cheese"; 
    } 
} 

爲什麼'然後'?如果沒有它,它會不會很明顯?

+1

標籤SO拒絕:奶酪,小東西,驅動你堅果。 – 2011-05-31 01:08:31

+0

對於什麼是值得的,我會使用+1來增加學習的方便性。當我第一次開始編程時,我討厭那個時候很容易閱讀的Python腳本。 – 2011-06-02 01:06:17

+0

猜猜我很習慣沒有'then'的語言(javascript,python),它總是讓我出差。 – 2011-06-02 03:49:05

回答

2

可能是因爲該語言的作者覺得加入then更自然。

+0

Tim在這裏是正確的。如果你記得parens()是可選的,它會有幫助:如果奶酪像re/bert /那麼{} – TelegramSam 2011-05-31 19:17:43

+0

感謝你的迴應。我想這允許像這樣的東西:如果奶酪像re/bert /然後通知(「法國奶酪」,「希望你有一個有效的護照!」); – 2011-06-02 03:46:43

相關問題