Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asBoolean message for flow operators #236

Merged
merged 1 commit into from Oct 4, 2013

Conversation

kgksoft
Copy link
Contributor

@kgksoft kgksoft commented Nov 23, 2012

Add message "asBoolean" to Object.

Now flow operators IF and WHILE can be writen in c-style (good for business logic):

check := method(a,
if(a,
"true",
"false"
) println
)

check(0) //true
check(1) //true
check("") //true
check("not empty") //true
check(Date clone fromNumber(0)) //true
check(Date clone now) //true

Number asBoolean := method(
self != 0
)

Sequence asBoolean := method(
self size != 0
)

Date asBoolean := method(
self asNumber != 0
)

check(0) //false
check(1) //true
check("") //false
check("not empty") //true
check(Date clone fromNumber(0)) //false
check(Date clone now) //true

a := 10
while (a,
a println
a = a - 1
)
//now print 10,9,....,1
//before 10,9,...,1,0,-1,.....

@gatesphere
Copy link

Nice idea.

stevedekorte added a commit that referenced this pull request Oct 4, 2013
asBoolean message for flow operators
@stevedekorte stevedekorte merged commit f682095 into IoLanguage:master Oct 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants