-
Notifications
You must be signed in to change notification settings - Fork 4.3k
for the issue: [Entry] Variables: Creating new concept entry variables.md #4237 #4428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3fb3501
Correct link to constructors in objects.md
zkhOlga 844c189
Add variables.md for Dart
zkhOlga b4b3f58
Revise variables.md
zkhOlga 5713029
Merge branch 'main' into variables_dart
zkhOlga fd57748
Merge branch 'main' into variables_dart
zkhOlga e1538cf
Apply minor suggestions from code review
zkhOlga f1de543
Add suggestions from the code review
zkhOlga 8a3b1e2
Add suggestions from the code review
zkhOlga 4845245
Formatting
dakshdeepHERE edf95ae
Merge branch 'main' into variables_dart
dakshdeepHERE 070be73
Merge branch 'main' into variables_dart
ishg-153 5e2b7f5
Merge branch 'main' into variables_dart
ishg-153 2d4960e
Merge branch 'main' into variables_dart
ishg-153 1ab9ff5
fix: structure
ishg-153 2134187
Merge branch 'main' into variables_dart
ishg-153 7b29d69
fix: format
ishg-153 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| --- | ||
| Title: 'Variables' | ||
| Description: 'A variable is a location in computer memory used to store data.' | ||
| Subjects: | ||
| - 'Code Foundations' | ||
| - 'Computer Science' | ||
| Tags: | ||
| - 'Variables' | ||
| - 'Data Types' | ||
| --- | ||
|
|
||
| A **`variable`** is a location in computer memory used to store references, usually for use in a program. Variables serve as symbolic names (identifiers) for values in the computer's memory. Variables allow programmers to manipulate and process data dynamically within their programs. | ||
|
|
||
| ## Syntax | ||
|
|
||
| When declaring a variable in Dart, the type of variable goes first, followed by the name, and then the value: | ||
|
|
||
| ```pseudo | ||
| type name = value; | ||
| ``` | ||
|
|
||
ishg-153 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - `type`: It can be any data type like `Int`, `String` or can also take the value `var`, `const`. | ||
| - `value`: This is what the variable `name` represents. It corresponds to the data type `type`. | ||
|
|
||
| > **Note:** The default type 'var' is inferred to be a `string`. | ||
|
|
||
| If an object isn't restricted to a single type, specify the Object type (or dynamic if necessary): | ||
|
|
||
| ```pseudo | ||
| Object name = 'value'; | ||
| ``` | ||
|
|
||
| The Dart Language enforces sound null safety, allows to set default values and constants, and declares the late variables. | ||
|
|
||
| ## Example | ||
|
|
||
| To display a constant name "Alex" one should write: | ||
|
|
||
| ```dart | ||
| void main() { | ||
| const name = 'Alex'; | ||
| print(name); | ||
| } | ||
| ``` | ||
|
|
||
| The output for the above code will be: | ||
|
|
||
| ```shell | ||
| Alex | ||
| ``` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.