0

I followed Swift Getting Started guide. I've made a typo in a simple statement and found a strange behavior:

$ swift
Welcome to Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1). Type :help for assistance.
1> 2 + 2
$R0: Int = 4
2> 2+2
$R1: Int = 4
3> 2 +2
error: repl.swift:3:2: error: consecutive statements on a line must be separated by ';'
2 +2
^
;

From where this limitation is coming? In other statically and dynamically typed languages like Scala and Python that works fine in REPL.

kisileno
  • 787
  • 9
  • 23
  • Scala and python don't support custom operators. This error is a consequence of the language grammar necessary for supporting user-defined operators. – Alexander Apr 08 '17 at 18:50
  • @MartinR is [this](http://stackoverflow.com/questions/40971207/simple-int-sum-error/) also related? – Ahmad F Apr 08 '17 at 18:56
  • @AhmadF: Well, it is another duplicate, but http://stackoverflow.com/questions/24964006/divided-operation-in-swift seems to be older. – Martin R Apr 08 '17 at 19:00
  • @MartinR I added it because I noticed that you are able to add three duplicated questions (for example: [this one](http://stackoverflow.com/questions/43298652/swift-3-can-not-convert-string-to-date/) before couple of minutes). obviously, I am not familiar with how to close answer as duplicated, I though it might help :) – Ahmad F Apr 08 '17 at 19:04
  • @AhmadF: You can "vote to close as a duplicate" if you think that a question has been asked and answered before. It requires 5 close votes to actually close a question. A gold badge holder can *immediately* close as a duplicate: https://meta.stackexchange.com/questions/230865/increase-close-vote-weight-for-gold-tag-badge-holders. The feature to add more than one duplicate (or remove) was implemented only recently: https://meta.stackexchange.com/questions/291824/gold-tag-badge-holders-and-moderators-can-now-edit-duplicate-links. – Martin R Apr 08 '17 at 19:15
  • @MartinR I see, I am familiar with "vote to close as a duplicate" -and I voted that many times-, but I meant the gold badge holders. Thank you for the clarification. – Ahmad F Apr 08 '17 at 19:25

0 Answers0