Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Striping Whitespace #67

Answered by phaniel1111
07KingKaiju07 asked this question in Q&A
Discussion options

You must be logged in to vote

The syntax should not be
favourite_language.stripEnd()
It should be
Text.stripEnd(favourite_language, #text " ")
stripEnd is a function in Text library so the syntax is Text.stripEnd()
Inside the stripEnd() we got 2 variables:
func stripEnd(t : [Text], p : [Pattern]) : ?[Text]
There are t is your Text, and p is the pattern Pattern = {#char : Char; #text : [Text]; #predicate : (Char -> Bool)}
In this case, we want to delete the white space in the text so we use #text " "

Here is the code:

actor {
    // Stripping Whitespace.
    let favourite_language = "Motoko ";
    Debug.print(debug_show(favourite_language));
    let favourite_language1 = Text.stripEnd(favourite_language, #text " ");
  …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by seb-icp
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants