Importing .swift file into REPL?


(Austin Zheng) #1

Hello developers,

Is there a way to import a .swift source file into the interactive REPL? There are times I'd like to debug code by importing it into the REPL and then typing in various interactive commands. However, copy-pasting does not always work properly, especially if the code is long and contains line breaks.

Best,
Austin


(Dmitri Gribenko) #2

I usually iterate in a separate source file and use the 'swift'
interpreter when I hit issues like this. Not a perfect workflow, but
does the job -- just a suggestion in case you're blocked.

Dmitri

ยทยทยท

On Wed, Apr 20, 2016 at 3:23 PM, Austin Zheng via swift-dev <swift-dev@swift.org> wrote:

Hello developers,

Is there a way to import a .swift source file into the interactive REPL? There are times I'd like to debug code by importing it into the REPL and then typing in various interactive commands. However, copy-pasting does not always work properly, especially if the code is long and contains line breaks.

--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr@gmail.com>*/