[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Ternary operator patch
- From: Ryota Hirose <hirose.ryota@...>
- Date: Fri, 10 Sep 2010 10:04:36 +0900
Hello, lua-users,
Attached patch is a ternary operator patch for Lua 5.1.4. I made it but I am not confidence that this patch is correct.
Could someone review my patch and point out any defect to me?
A syntax of ternary op. is if/then/else, so it is like haskell. You can write a code as following:
a = if x == y then good() else bad()
c = string.char(x + (if x < 10 then string.byte('0') else string.byte('A') - 10))
A priority of if/then/else operator is lowest.
Thank you,
Ryota Hirose
Attachment:
lua-ifexpr.diff
Description: Binary data