Function in io::sync coil-stdlib

println

fn println(string s) -> Result<int, IoError>
Import
use io::sync::{println};
Source: src/io/sync.hy

Writes s and a newline to standard output.

The usual way to print. It returns a Result like all IO, so write println(…)?; in a function that can return the error (main can). Build the text with string::format.

Parameters#

NameType
sstring

Returns#

Result<int, IoError>

Errors#

Returns Err when standard output cannot be written (for example, a closed pipe).

Examples#

use io::sync::{println};
use string::{format};

fn main() {
    println("Hello, Coil!")?;
    println(format("%i + %i = %i", 2, 2, 2 + 2))?;
}

See also#

  • Result
  • string::format
  • write_all: Writes all of buf to s, waiting whenever the stream is not ready.
  • read_exact: Fills all of buf from s, waiting whenever no data is ready.
  • read_to_end: Reads from s until it ends and returns everything read.
  • accept_wait: Waits for the next connection on a TCP listener and returns its stream.
  • recv_from_wait: Waits for a UDP datagram, reads it into buf, and returns (bytes, sender host, sender port).
  • send_to_wait: Sends buf as one UDP datagram to host:port, waiting while the socket is not ready.
↑ ↓ navigate ↵ open