February 2015
Intermediate to advanced
124 pages
2h 31m
English
Like most scripting languages, CoffeeScript has a REPL (“read-eval-print loop,” a term that originated with Lisp) where you can run commands interactively. To enter the REPL, just run coffee:
| | $ coffee |
| | coffee> audience = 'world' |
| | 'world' |
| | coffee> "Hello, #{audience}!" |
| | 'Hello, world!' |
To exit the REPL, press Ctrl-d.
The REPL handily shows you the output of each expression you enter. However, editing nontrivial amounts of code on the REPL is a pain. So how do we make coffee evaluate code written in our favorite text editor?
Create a file named hello.coffee with this code:
| GettingStarted/hello.coffee | |
| | rl = require('readline').createInterface |
| | input: process.stdin |
| | output: process.stdout |
| | |
| | rl.question ... |
Read now
Unlock full access