J'ai un problème quand j'ai essayé de compiler un code Swift, je crois que c'est quelque chose à propos de Swift dans Ubuntu. Voici l'erreur:Erreur avec "build rapide" dans Ubuntu 14.04
swift build
Compiling Swift Module 'testregex' (1 sources)
/home/guillermo/Descargas/Hola/Sources/testregex.swift:4:1: error: statements are not allowed at the top level
if let range = str.rangeOfString("string$", options: .RegularExpressionSearch) { ^
<unknown>:0: error: build had 1 command failures
error: exit(1): ["/home/guillermo/Descargas/swift-DEVELOPMENT-SNAPSHOT-2016-01-25-a-ubuntu14.04/usr/bin/swift-build-tool", "-f", "/home/guillermo/Descargas/Hola/.build/debug/testregex.o/llbuild.yaml"]
Si quelqu'un sait comment résoudre ce problème bizarre, je serai très reconnaissant :)
Veuillez montrer le code correspondant. – Moritz
importation Fondation let str = "Je suis une chaîne" si laisser range = str.rangeOfString ("string $", les options: .RegularExpressionSearch) { print ("Se termine par 'string'") } –
mais, Je mets une impression simple ("bonjour monde"), et affiche la même erreur –