Skip to content

Rewritten functions#386

Closed
aster-void wants to merge 17 commits into
ut-code:masterfrom
aster-void:rewrite-functions
Closed

Rewritten functions#386
aster-void wants to merge 17 commits into
ut-code:masterfrom
aster-void:rewrite-functions

Conversation

@aster-void
Copy link
Copy Markdown
Contributor

・演習の引数名の修正 (bandwidthは帯域幅)
・returnで複数の条件の付いた処理の可読性を上げることができることについての追加
・モジュール化の説明の追加

Comment thread src/components/Term/definitions.js Outdated
Comment thread src/components/Term/definitions.js
Comment thread docs/1-trial-session/09-functions/index.md Outdated
Comment thread docs/1-trial-session/09-functions/index.md Outdated
Comment thread docs/1-trial-session/09-functions/index.md Outdated
Comment thread docs/1-trial-session/09-functions/index.md Outdated
Comment thread docs/1-trial-session/09-functions/index.md Outdated
Comment thread src/components/Term/definitions.js
## <Term type="javascriptReturnValue">戻り値</Term>

<p><Term type="javascriptFunction">関数</Term>呼び出しは<Term type="javascriptExpression">式</Term>の一種です。<Term type="javascriptFunction">関数</Term>定義内で <strong>return 文</strong>を用いると、<Term type="javascriptFunction">関数</Term>の実行が停止され、<Term type="javascriptFunction">関数</Term>呼び出し<Term type="javascriptExpression">式</Term>の<Term type="javascriptEvaluation">評価</Term>結果が確定します。この値を<Term strong type="javascriptReturnValue">戻り値</Term>と呼びます。ある<Term type="javascriptValue">値</Term>を<Term type="javascriptReturnValue">戻り値</Term>として設定して関数の実行を終了することを、<Term type="javascriptFunction">関数</Term>がその<Term type="javascriptValue">値</Term>を<Term strong type="javascriptReturn">返す</Term>と表現します。</p>
<p><Term type="javascriptFunction">関数</Term>呼び出しは<Term type="javascriptExpression">式</Term>の一種です。<Term type="javascriptFunction">関数</Term>定義内で **return 文** を用いると、<Term type="javascriptFunction">関数</Term>の実行が停止され、<Term type="javascriptFunction">関数</Term>呼び出し<Term type="javascriptExpression">式</Term>の<Term type="javascriptEvaluation">評価</Term>結果が確定します。この値を<Term strong type="javascriptReturnValue">戻り値</Term>と呼びます。ある<Term type="javascriptValue">値</Term>を<Term type="javascriptReturnValue">戻り値</Term>として設定して関数の実行を終了することを、<Term type="javascriptFunction">関数</Term>がその<Term type="javascriptValue">値</Term>を<Term strong type="javascriptReturn">返す</Term>と表現します。</p>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docusaurusの仕様で、文頭にTermコンポーネントを書くとMarkdownが正常にレンダリングされないというバグがあります。そのため、その場合だけpタグで囲むということをしています。逆に、そうした場合Markdownで書くとレンダリングされなくなってしまいます...
ちなみに、これはDocusaurus 3.0で修正される予定です。


<video src={returnValueVideo} controls autoPlay muted loop />

:::tip <strong>return文</strong>が実行された時点で関数が終了するため、次のように書くことで [if ~ else 文](../07-if-statement/index.md/#if--else-if--else)や [|| (OR) 演算子](../06-boolean/index.md/#%E8%AB%96%E7%90%86%E6%BC%94%E7%AE%97%E5%AD%90)の繰り返しを避けつつ、複数の条件のついた処理を実行することができます。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

逆に、こっちだとMarkdownの記法が使えます。


<video src={returnValueVideo} controls autoPlay muted loop />

:::tip <strong>return文</strong>が実行された時点で関数が終了するため、次のように書くことで [if ~ else 文](../07-if-statement/index.md/#if--else-if--else)や [|| (OR) 演算子](../06-boolean/index.md/#%E8%AB%96%E7%90%86%E6%BC%94%E7%AE%97%E5%AD%90)の繰り返しを避けつつ、複数の条件のついた処理を実行することができます。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

それとここもindex.mdがある場合で動くのか気になります。


```javascript
function calculateCost(monthlyBandwidth) {
function calculateCost(monthlyDataUse) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHubのキーワード検索で調べてみたんですが、monthlyBandwidthだと407件、monthlyDataUsageだと83件、monthlyDataUseだと6件なので、monthlyBandwidthとかがいい気がします。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Monthly Bandwidthをgoogleで検索して上から4サイトくらい見ると、月間の交通量 = バックエンドというかホストというかサーバー側の データ使用量制限 / データ速度制限 のことらしいです
https://help.podbean.com/support/solutions/articles/25000004919-what-is-monthly-space-and-bandwidth-
https://tr-ex.me/%E7%BF%BB%E8%A8%B3/%E8%8B%B1%E8%AA%9E-%E6%97%A5%E6%9C%AC%E8%AA%9E/monthly+bandwidth#gref

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

たしかに、bandwidthはちょっと意味合いが違いますねm(_ _)m
monthlyDataUsageあたりが良さげ。

>
> - _monthlyBandwidth_ < 5.0 のとき、携帯電話料金は _monthlyBandwidth_ × 600 (円)
> - _monthlyBandwidth_ >= 5.0 のとき、携帯電話料金は 3000 (円)
> 
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要な空白がありそう。

@aster-void aster-void closed this by deleting the head repository Sep 27, 2023
@aster-void
Copy link
Copy Markdown
Contributor Author

ut-codeリポ内のrewrite-functionsブランチにマージしたのでそっちを参照してください

@chvmvd chvmvd mentioned this pull request Sep 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants