From 32edf6998b180e38ce456a72ac3c16981ced17b1 Mon Sep 17 00:00:00 2001 From: bobszi <46566390+bobszi@users.noreply.github.com> Date: Thu, 17 Apr 2025 15:59:14 +0200 Subject: [PATCH] Clarify specification of example function used in ch04-03 Added some clarification to the input requirements of the function, because the implementation of the function in the chapter does not work correctly with inputs that have one or more leading spaces. --- src/ch04-03-slices.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ch04-03-slices.md b/src/ch04-03-slices.md index ca7a8e4e2d..d064ff1343 100644 --- a/src/ch04-03-slices.md +++ b/src/ch04-03-slices.md @@ -8,6 +8,8 @@ Here’s a small programming problem: write a function that takes a string of words separated by spaces and returns the first word it finds in that string. If the function doesn’t find a space in the string, the whole string must be one word, so the entire string should be returned. +The function doesn't need to handle input strings that have leading space +characters. Let’s work through how we’d write the signature of this function without using slices, to understand the problem that slices will solve: