Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Assignment and a boolean operator #27

Open
voddan opened this issue Jul 1, 2016 · 6 comments
Open

Assignment and a boolean operator #27

voddan opened this issue Jul 1, 2016 · 6 comments

Comments

@voddan
Copy link

voddan commented Jul 1, 2016

In a case of "assignment" syntax with a boolean expression == put brackets around the expression:

Good:

// assignment:
val x: Boolean = (this == other)

// expression body:
fun foo() = (a == b)

// function expression:
 doStaff(fun(x: Int) = (x == 1))

Bad:

val x: Boolean = this == other
fun foo() = a == b
doStaff (fun(x: Int) = x == 1)

The idea is to visual separate = and ==

@cypressious
Copy link

Not sure I agree. What's the benefit.

@igor-korotenko
Copy link

igor-korotenko commented Jul 1, 2016

What does doStaff (fun(x: Int) = x == 1) line mean?

@voddan
Copy link
Author

voddan commented Jul 1, 2016

The benefit is in visual separating = and ==

@voddan
Copy link
Author

voddan commented Jul 1, 2016

@igor-korotenko doStaff() is a method accepting a lambda (edited)

@voddan
Copy link
Author

voddan commented Jul 1, 2016

Also I think the brackets improve similar situations with other comparison operators:

val x = (100 > 200)

vs

val x = 100 > 200

But that does not apply to other operators. Complitelly OK:

val x = 1 + 2
val y = a && b
val x = c or d

@igor-korotenko
Copy link

Look like a quite cool idea and I see some visual benefits, but most of code we meet every day don't have this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants