Data Types (part 1) - Value Types | Vyper (0.2) - Çift Dilli Altyazılar

Let's learn about the different data types in Piper.
Each data type is either a value or a reference.
In this video, we'll go over value types, and in the next video, we'll go over references.
First of all, what are value types?
value types are data types that are passed by their values.
For example, let's say that we have an unsigned integer named x and it is equal to 1.
And then we reassign variable x to a variable named y.
And then we modify the variable y.
For example, we add one to its current value.
Now the big question is, what is the value of x?
And the answer is x is still equal to one.
This is because when we assign x to y, the value of x was copied over to a variable y.
So that when we change the value of variable y, it doesn't change the value of x.
So that's value types.
They copy variables by their variable y.
so that making a change to one variable does not affect the other variable.
Let's now take a look at value types available in Viper.
The first value type that I'm going to show you is a Boolean.
So I'll name it B and then we'll say it's a public variable and up type.
Boo.
By declaring this variable as public, we'll be able to access this variable after we deploy it using Remix.
I'll make a separate video about the different visibility of the variable.
For now let's just go over what this line of code is doing.
Here we're declaring our variable named called b.
The type of this variable is a boolean and it is a public variable which means that we'll be able to get the value of this b variable after the contract is deployed.
All moving on another value type is int 128.
So we will name it i and then it will be public and we can declare the type has int 128.
The range of this variable goes from negative 2 to the 127 to 2 to the 127.
So this is the data type that you will want to use when you want to handle both negative and positive numbers.
Next, we have Uint 256, which ranges from 0 to 256 minus 1.
and this is the variable to use when you're only dealing with non-negative numbers.
In Viper we also have decimals.
The range of decimals is same as in 128 and it supports up to 10 decimal places.
Now this is a useful data type that is not available in Solidity.
Alright, moving on, we have our address type.
Bites 32 and it's useful when you want to store the cryptographic cache of something.
Now surprisingly we also have byte arrays and strings as value types.
So this means that every time you copy a byte array or a string, it will copy each element in the array.
If you have a string of length 1000 and then reassign it to another variable.
Basically are running a for loop for 1000 characters copying each element.
Let's quickly go over what these two lines of code are doing.
For the first one, BS, we're declaring a variable named BS, and it's a public variable.
The data type is bytes, and this byte is at most 100.
Likewise, first chains were declaring a variable named s, it's a public variable,
of type string, and this variable can be at most 100 characters long.
These are the value types available in Viper.
Let's set these variables to some concrete value.
So we'll define init function.
And the first thing that we need to do is say, add external, and say def to underscores init to underscores parentheses calling.
Now this external means that this init function can be called from outside of the contract.
and then we'll set the variable b to true by saying self dot b equals true.
We'll set i to minus 1 by saying self dot i equals minus 1.
We'll set the unsigned variable to some positive number.
We want to We'll set the decimal to 3.14 and we'll set the address type to some random
address and then the bytes 32 to also some random bytes 32.
The byte array,
we also set it to some random byte,
and we'll say that it's a byte by prefixing with a b, double quotes, slash x, and then the value, 0, 1.
For the string, we'll say this is a string.
Let's make sure that this contract compiles.
So I'm going to open my terminal and type Viper, followed by the name of the contract here.
I named it value types.
And you can see that our contract compile is run through a demo using remix.
So I'm going to copy the code.
Open remix.
And then activate Viper.
Next, I'll create a Viper file.
Here, I'll name it value type.by paste the code.
And then click on the biker compiler and then click remote compiler and then click compile All right,
let's deploy this contract,
so I'm gonna click deploy scroll down and then click on the contract that was just deployed and let's check that
these variables are set to these values over here address b is for boolean b32 is bytes 32 bs is bytes array g is decimal.
Note that remix does not know how to handle decimal types yet.
Alright, moving on, let's check the value of int 128.
It's equal to minus one.
the string value, this is a string, and the on-site value is 1 to 3, right?
So are the value types of Viper, Boolean, on-site and signed integers, decimals, edges, bytes 32, and also strings and bytes array.
The last two data types being a value type is a little bit surprising, since in Solidity these two types are reference types.

Daha Fazla Özelliği Açın

Trancy uzantısını yükleyerek, AI altyazılar, AI kelime tanımları, AI dilbilgisi analizi, AI konuşma vb. dahil olmak üzere daha fazla özelliği açabilirsiniz.

feature cover

Büyük Video Platformlarıyla Uyumlu

Trancy, YouTube, Netflix, Udemy, Disney+, TED, edX, Kehan, Coursera gibi platformlar için çift dilli altyazı desteği sağlamakla kalmaz, aynı zamanda düzenli web sayfaları için AI kelime/cümle çevirisi, tam metin etkileşimli çeviri ve diğer özellikler sunar. Gerçek bir çok yönlü dil öğrenme asistanıdır.

Tüm Platform Tarayıcıları

Trancy, iOS Safari tarayıcı uzantısı dahil olmak üzere tüm platform tarayıcılarını destekler.

Çoklu Görüntüleme Modları

Tiyatro, okuma, karışık ve diğer görüntüleme modlarını destekleyerek kapsamlı bir çift dilli deneyim sunar.

Çoklu Uygulama Modları

Cümle dikte, sözlü değerlendirme, çoktan seçmeli, dikte ve diğer uygulama modlarını destekler.

AI Video Özeti

Videoları özetlemek ve hızlı bir şekilde temel içeriği kavramak için OpenAI kullanın.

AI Altyazılar

Sadece 3-5 dakikada doğru ve hızlı YouTube AI altyazıları oluşturun.

AI Kelime Tanımları

Altyazılardaki kelimelere dokunarak, AI destekli tanımlarıyla kelime anlamlarını öğrenin.

AI Dilbilgisi Analizi

Cümle dilbilgisini analiz ederek cümle anlamlarını hızlıca anlayın ve zor dilbilgisi konularını öğrenin.

Daha Fazla Web Özelliği

Çift dilli video altyazılarının yanı sıra, Trancy ayrıca web sayfaları için kelime çevirisi ve tam metin çevirisi sağlar.

Başlamak için hazır

Trancy'yi bugün deneyin ve benzersiz özelliklerini kendiniz deneyimleyin.

İndir