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
* tételsorok
* jegyzetek
* szakdolgozat / PhD
* ösztöndíjak
* certificates
* C lang.
* C#
* D lang.
* Java
* Nim
* Nim2
  + exercises
* XC=BASIC
* old
  ✦C++, ✦Clojure, ✦Scala


[ edit | logout ]
[ sandbox | passwd ]

Mutable or immutable?

In Python, a string is immutable.

In Nim, a string can be mutable (var) or immutable (let). It depends on how you declare it.

Immutable

let s = "hello"

echo s      # "hello"

echo s[0]   # 'h'

s[0] = 'H'  # ERROR!

Like in Python.

Mutable

var s: string

echo s      # "" , empty string

s.add("hello")

echo s      # "hello"

s[0] = 'H'
echo s      # "Hello"

s.add(" World!")

echo s      # "Hello World!"

As you can see, it also works as a stringbuffer! We don't need a special StringBuffer type in Nim. Just use a mutable string for this purpose.

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 05, 11:35