Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

countElements has been renamed to count #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions 3. Strings and Characters.playground/section-1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ for character in originalString
var notAString: Character = "t"

// There is no length or count member of string, you have to use the global function,
// countElements()
// count()
//
// This is much like calling strlen in which it iterates over the Unicode string and counts
// characters. Note that Unicode chars are different lenghts, so this is a non-trivial process.
//
// “Note also that the character count returned by countElements is not always the same as the
// “Note also that the character count returned by count() is not always the same as the
// length property of an NSString that contains the same characters. The length of an NSString is
// based on the number of 16-bit code units within the string’s UTF-16 representation and not the
// number of Unicode characters within the string. To reflect this fact, the length property from
// NSString is called utf16count when it is accessed on a Swift String value.”
countElements(originalString)
count(originalString)

// Strings can be concatenated with strings and characters
var helloworld = "hello, " + "world"
Expand Down