Skip to content

Commit

Permalink
#55 Remove underscore assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
angelolloqui committed Dec 7, 2017
1 parent b324950 commit bf1a790
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
7 changes: 7 additions & 0 deletions Sources/SwiftKotlinFramework/KotlinTokenizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,13 @@ public class KotlinTokenizer: SwiftTokenizer {

// MARK: - Expressions

open override func tokenize(_ expression: AssignmentOperatorExpression) -> [Token] {
guard expression.leftExpression is WildcardExpression else {
return super.tokenize(expression)
}
return tokenize(expression.rightExpression)
}

open override func tokenize(_ expression: LiteralExpression) -> [Token] {
switch expression.kind {
case .nil:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,3 @@ when (nb) {
}
else -> print("three or more digits")
}
val value = if (isTrue) "yes" else "no"
val label = if (x > 0) "Positive" else "negative"
button.color = if (item.deleted) red else green
val text = label ?: "default"
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,3 @@ switch nb {
default: print("three or more digits")
}

// Ternary and coalescing operators
let value = isTrue ? "yes" : "no"
let label = x > 0 ? "Positive" : "negative"
button.color = item.deleted ? red : green
let text = label ?? "default"


Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

val value = if (isTrue) "yes" else "no"
val label = if (x > 0) "Positive" else "negative"
button.color = if (item.deleted) red else green
val text = label ?: "default"
service.deleteObject()
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@


// Ternary and coalescing operators
let value = isTrue ? "yes" : "no"
let label = x > 0 ? "Positive" : "negative"
button.color = item.deleted ? red : green
let text = label ?? "default"

// Wilcard assignments
_ = service.deleteObject()

0 comments on commit bf1a790

Please sign in to comment.