Data Types (part 1) - Value Types | Vyper (0.2) - 이중 자막

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.
번역 언어
번역 언어 선택

더 많은 기능 잠금 해제

Trancy 확장 프로그램을 설치하면 AI 자막, AI 단어 정의, AI 문법 분석, AI 구술 등을 포함한 더 많은 기능을 사용할 수 있습니다.

feature cover

인기 있는 비디오 플랫폼과 호환

Trancy는 YouTube, Netflix, Udemy, Disney+, TED, edX, Kehan, Coursera 등의 플랫폼에서 이중 자막을 지원하는데 그치지 않고, 일반 웹 페이지에서 AI 단어/문장 번역, 전체 문장 번역 등의 기능도 제공하여 진정한 언어 학습 도우미가 됩니다.

다양한 플랫폼 브라우저 지원

Trancy는 iOS Safari 브라우저 확장 프로그램을 포함하여 모든 플랫폼에서 사용할 수 있습니다.

다양한 시청 모드

극장, 읽기, 혼합 등 다양한 시청 모드를 지원하여 전체적인 이중 자막 체험을 제공합니다.

다양한 연습 모드

문장 청취, 구술 평가, 선택 공백, 테스트 등 다양한 연습 방식을 지원합니다.

AI 비디오 요약

OpenAI를 사용하여 비디오 요약을 생성하여 핵심 내용을 빠르게 파악할 수 있습니다.

AI 자막

3-5분 만에 YouTube AI 자막을 생성하여 정확하고 빠른 자막을 제공합니다.

AI 단어 정의

자막에서 단어를 탭하면 정의를 검색하고 AI 단어 정의 기능을 활용할 수 있습니다.

AI 문법 분석

문장에 대한 문법 분석을 수행하여 문장의 의미를 빠르게 이해하고 어려운 문법을 습득할 수 있습니다.

더 많은 웹 기능

Trancy는 비디오 이중 자막 뿐만 아니라 웹 페이지의 단어 번역 및 전체 문장 번역 기능도 제공합니다.

시작 준비되셨나요?

Trancy를 오늘 시도하고 독특한 기능들을 직접 경험해보세요.

다운로드