Difference between revisions of "W1215 Function Signatures"
From Coder Merlin
Line 12: | Line 12: | ||
Create a directory within your "project" directory. | Create a directory within your "project" directory. | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
cd ~/ | cd ~/Experiences | ||
mkdir | mkdir W1215 | ||
cd | cd W1215 | ||
swift-init | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 22: | Line 23: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{Hint| | |||
For this project you'll repeatedly edit the same file. It's probably easiest to test this file ''within emacs'' by typing: | For this project you'll repeatedly edit the same file. It's probably easiest to test this file ''within emacs'' by typing: | ||
{{Key|F5}}-{{Key|r}} and observing the results. For each question, be sure to '''understand''' the behavior before proceeding to the next question. It will be helpful to '''record''' your answers and reasoning for later review. | |||
}} | |||
<quiz shuffleanswers=true display=simple> | <quiz shuffleanswers=true display=simple> |
Latest revision as of 22:51, 19 January 2021
Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder
Prerequisites[edit]
Research[edit]
Function signatures consist of the function's name (identifier); parameter arity, types, names, and order; and the function's return type. (Note that various languages treat some of these items differently. For example, not all languages allow for a different return type if the signature is otherwise identical.)
- Read Functions (First paragraph only) (Swift Documentation)
- Read Type Signature (Wikipedia)
- Read Computer Science I Textbook (by Bourke) Chapter 5.1.1. Function Signatures
Experiment[edit]
Create a directory within your "project" directory.
cd ~/Experiences
mkdir W1215
cd W1215
swift-init
Edit a new file named "main.swift"
emacs main.swift
Helpful Hint
For this project you'll repeatedly edit the same file. It's probably easiest to test this file within emacs by typing: F5-r and observing the results. For each question, be sure to understand the behavior before proceeding to the next question. It will be helpful to record your answers and reasoning for later review.