空字串
在計算機科學或形式語言中,空字串是指在字母表Σ上,其長度為 0 的那唯一字串,以ε或λ來標記。
在物件導向程式語言中,空字串共非空參照。一個字串型別的空參照並未指向一個字串物件,而對其操作則會導致錯誤。空字串則可以使用字串運算。
表示方式
空字串通常使用和其它一般字串相同的方式來表示。在使用結束字符的語言(如C字串或純文字的一行)中,則單統地將結束字符放在第一個位置。
| 程式語言 | λ 表示法 |
|---|---|
| C語言, C++ | ""{'\0'} |
| C++ | std::string() |
| Objective-C | @"" |
| Perl | ""''qw() |
| Python | ""''""""""str() |
| C# | ""string.Empty |
| Visual Basic .NET | ""String.Empty |
| PHP | ""'' |
| Java | "" |
| Javascript | ""'' |
| Haskell | "" |
| OCaml | ""String.make 0 '-' |
| Delphi | '' |
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.