0Pricing
Mojo Academy · レッスン

文字列とテキスト

テキスト値を保存して結合します

「文字列とテキスト」はCoddyKit上の無料Mojo Academyレッスンです。 これはレッスン3/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはMojo Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Mojo Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

Text Is a String

Any sequence of characters, like a name or a message, is a String. It is how programs hold human-readable text. 💬

Make a String

Wrap text in double quotes to create a String, then store it in a var so you can reuse the text later.

var name = "Ada"

Single or Double Quotes

Mojo accepts both quote styles. Pick the one that lets your text stay clean, like single quotes around a phrase with a quote inside.

var word = 'hello'

Joining Text with +

Put two Strings together using +. This is called concatenation and it builds a longer string from pieces.

var greeting = "Hi, " + name

Mind the Spaces

Concatenation glues text exactly as written. Add a space inside a String so words do not collide when joined.

var full = "Ada" + " " + "Lovelace"

Printing Text

print sends a String to the screen. It is your quickest way to see what a String currently holds.

print("Hello, world")

Empty and Long Strings

A String can be empty ("") or hold a whole sentence. Length is up to you; the type stays the same either way.

var blank = ""

Numbers Are Not Text

"42" is a String, while 42 is an Int. They look alike but behave differently, so keep text and numbers distinct.

var label = "42"

Turning a Number into Text

To join a number into a message, convert it with String first so the + has two strings to combine.

var msg = "Score: " + String(score)

Strings Describe Your Program

Labels, prompts, and messages are all Strings. Clear text makes your output friendly for the person reading it.

Text Powers Communication

From greetings to error messages, Strings carry meaning to users. Mastering text is half of writing useful programs.

Quick Check

You have a number in score and want to put it inside a text message. What do you do first?

Recap

A String holds text in quotes, joins with +, and prints to the screen. Convert numbers to String before mixing them in. 🎯

よくある質問

「文字列とテキスト」レッスンは無料ですか?

はい。「文字列とテキスト」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Mojo Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Mojo Academyコースには全4レッスンが含まれています。

「文字列とテキスト」で何を学びますか?

テキスト値を保存して結合します ブラウザで直接実行するハンズオンコードでMojo Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Mojo Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのMojo Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン3/4です。

「文字列とテキスト」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このMojo Academyレッスンでコードを書いて実行できますか?

はい。すべてのMojo Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. varによる値の宣言
  2. Int、Float、Bool
  3. 文字列とテキスト
  4. 役立つ型アノテーション
← Mojo Academyに戻る