Make minor changes to types: basics.
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
parent
ed4fcf5e9d
commit
72fb69d87b
|
@ -52,7 +52,7 @@ int x = 0;
|
||||||
```
|
```
|
||||||
|
|
||||||
Things in C++, C#, and many other languages look very similar.
|
Things in C++, C#, and many other languages look very similar.
|
||||||
In rust, we have to make an even finer distinction: we have to
|
In Rust, we have to make an even finer distinction: we have to
|
||||||
distinguish between integers represented using 32 bits and those
|
distinguish between integers represented using 32 bits and those
|
||||||
represented by 64 bits. Focusing on the former, we
|
represented by 64 bits. Focusing on the former, we
|
||||||
could write:
|
could write:
|
||||||
|
@ -70,7 +70,7 @@ assign it to a variable; the following suffices.
|
||||||
|
|
||||||
That should be enough examples of integers for now. I'm sure you've seen
|
That should be enough examples of integers for now. I'm sure you've seen
|
||||||
them in your programming or computer science career. What you
|
them in your programming or computer science career. What you
|
||||||
may not have seen, though, is the formal / mathematical way of
|
may not have seen, though, is the formal, mathematical way of
|
||||||
stating that some expression or value has a particular type.
|
stating that some expression or value has a particular type.
|
||||||
In the mathematical notation, too, there's no need to assign a value to
|
In the mathematical notation, too, there's no need to assign a value to
|
||||||
a variable to state its type. The notation is actually very similar
|
a variable to state its type. The notation is actually very similar
|
||||||
|
@ -82,7 +82,7 @@ the that of Haskell; here's how one might write the claim that 1 is a number.
|
||||||
|
|
||||||
There's one more difference between mathematical notation and the
|
There's one more difference between mathematical notation and the
|
||||||
code we've seen so far. If you wrote `num`, or `aNumber`, or anything
|
code we've seen so far. If you wrote `num`, or `aNumber`, or anything
|
||||||
other than just `numbeer` in the TypeScript example (or if you similarly
|
other than just `number` in the TypeScript example (or if you similarly
|
||||||
deviated from the "correct" name in other languages), you'd be greeted with
|
deviated from the "correct" name in other languages), you'd be greeted with
|
||||||
an error. The compilers or interpreters of these languages only understand a
|
an error. The compilers or interpreters of these languages only understand a
|
||||||
fixed set of types, and we are required to stick to names in that set. We have no such
|
fixed set of types, and we are required to stick to names in that set. We have no such
|
||||||
|
@ -202,7 +202,7 @@ plain old values like `1` gets boring quickly. There's not many programs you can
|
||||||
with them! Numbers can be added, though, why don't we look at that? All mainstream
|
with them! Numbers can be added, though, why don't we look at that? All mainstream
|
||||||
languages can do this quite easily. Here's Typescript:
|
languages can do this quite easily. Here's Typescript:
|
||||||
|
|
||||||
```
|
```TypeScript
|
||||||
const y = 1+1;
|
const y = 1+1;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user