You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for line in lines.split(separator: "\n", omittingEmptySubsequences: true) {
var x: String
if line.starts(with: "BuildVersion") {
x = String(line.split(separator: """)[1])
} else if line.starts(with: "ProductType") {
x = line.split(separator: """)[1]
.trimmingCharacters(in: CharacterSet.letters.inverted)
.lowercased()
} else if line.starts(with: "HWModelStr") {
let y = line.split(separator: """)[1]
if y.hasSuffix("AP") {
x = String(y.dropLast(2))
} else {
x = String👍
}
} else {
x = ""
}
print❌
}
Which works in Darwin land,
>>>
123
someproduct
TotallyNot
but on Linux I get errors like
error: terminated(1): /usr/bin/swift-build-tool -f /swift-execution/.build/debug.yaml main
ERROR at line 34, col 40: value of type 'Substring.SubSequence' (aka 'Substring') has no member 'trimmingCharacters'
x = line.split(separator: """)[1]
~~~~~~~~~~~~~~~~~~~~~~~~~~^~
ERROR at line 39, col 12: value of type 'Substring.SubSequence' (aka 'Substring') has no member 'hasSuffix'
if y.hasSuffix("AP") {
^ ~~~~~~~~~
I would expect these functions to work here.
The text was updated successfully, but these errors were encountered:
Environment
Linux w/ Swift 4
Additional Detail from JIRA
md5: 817ca51797142c68cbaea3fcdd3f2e76
Issue Description:
I'm trying to do some string processing that looks something like this:
import Foundation
let lines = """
BuildVersion: "123"
ProductType: "SomeProduct1,2"
HWModelStr: "TotallyNotAP"
"""
for line in lines.split(separator: "\n", omittingEmptySubsequences: true) {
var x: String
if line.starts(with: "BuildVersion") {
x = String(line.split(separator: """)[1])
} else if line.starts(with: "ProductType") {
x = line.split(separator: """)[1]
.trimmingCharacters(in: CharacterSet.letters.inverted)
.lowercased()
} else if line.starts(with: "HWModelStr") {
let y = line.split(separator: """)[1]
if y.hasSuffix("AP") {
x = String(y.dropLast(2))
} else {
x = String👍
}
} else {
x = ""
}
print❌
}
Which works in Darwin land,
>>>
123
someproduct
TotallyNot
but on Linux I get errors like
error: terminated(1): /usr/bin/swift-build-tool -f /swift-execution/.build/debug.yaml main
ERROR at line 34, col 40: value of type 'Substring.SubSequence' (aka 'Substring') has no member 'trimmingCharacters'
x = line.split(separator: """)[1]
~~~~~~~~~~~~~~~~~~~~~~~~~~^~
ERROR at line 39, col 12: value of type 'Substring.SubSequence' (aka 'Substring') has no member 'hasSuffix'
if y.hasSuffix("AP") {
^ ~~~~~~~~~
I would expect these functions to work here.
The text was updated successfully, but these errors were encountered: