Recent Changes - Search:

Oktatás

* Programozás 1
  + feladatsor
  + GitHub oldal

* Szkriptnyelvek
  + feladatsor
  + quick link

Teaching

* Programming 1 (BI)
  ◇ exercises
  ◇ quick link

teaching assets


Félévek

* 2025/26/2
* archívum


Linkek

* kalendárium
   - munkaszüneti napok '20
* tételsorok
* jegyzetek
* szakdolgozat / PhD
* ösztöndíjak
* certificates
* C lang.
* C++
* C#
* Clojure
* D lang.
* Java
* Nim
* Nim2
* Scala


[ edit | logout ]
[ sandbox | passwd ]

String

Very similar to Python.

let
  text = "hello world"

  path = r"C:\Program files\Notepad++"

  html = """
<title>Nim</title>
<h1>hello</h1>
"""


echo text
echo ""
echo path
echo ""
echo "'" & html & "'"

Output:

hello world

C:\Program files\Notepad++

'<title>Nim</title>
<h1>hello</h1>
'

Notice that the multiline string behaves a bit differently from Python. The leading newline character is not present.

This is actually intentional Nim behavior — Nim's triple-quoted strings strip the first newline if it immediately follows the opening """.

Strip

If you don't need the leading and trailing whitespaces, just strip it:

import std/strutils    # strip, split, join

let
  html = """
<title>Nim</title>
<h1>hello</h1>
"""
.strip

echo "'" & html & "'"
'<title>Nim</title>
<h1>hello</h1>'
Cloud City

  

Blogjaim, hobbi projektjeim

* The Ubuntu Incident
* Python Adventures
* @GitHub
* heroku
* extra
* haladó Python
* YouTube listák


Debrecen | la France


[ edit ]

Edit - History - Print *** Report - Recent Changes - Search
Page last modified on 2026 April 03, 11:45