DEV Community

keepoSteepo
keepoSteepo

Posted on

1

Different Types of Functions

Contain functions are functions that are made from scratch, per se. These are function in which every component in the function is defined to achieve a desired outcome. The hasPrefix and hasSuffix functions are built in functions for a certain type, which just so happens to be type String. They are functions that do not have to be created from scratch every time, they were pre built into the type.

A problem that is sure to be encountered if the user inputs uppercase or lowercase is when a function is tied to certain case. The function might be able to take any input in that starts with a certain value, but if it is tied to a certain case it will not return the desired outcome.
Fear not, there is a fix for this. Instead of writing a function for each possible case, one might change the case of the text before trying to match it using the lowercased method.

let lowerQuestion = question.lowercased()
lowerQuestion.hasPrefix(“where”)>

Sentry mobile image

Improving mobile performance, from slow screens to app start time

Based on our experience working with thousands of mobile developer teams, we developed a mobile monitoring maturity curve.

Read more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs