Skip to content

Commit 2eda647

Browse files
author
theunicorndev237
committed
comparison operators
1 parent 4030866 commit 2eda647

9 files changed

+39
-6
lines changed

002-variable-and-types.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pragma solidity >=0.7.0 <0.9.0;
1515
// walletAmount = integer, total amount in users wallet
1616
// errorMessage = a string containing a description of what went wrong
1717

18-
contract learnVariables {
18+
contract LearnVariables {
1919
// our solidity code
2020

2121
// declaring an integer variable

003-functions-in-solidity.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pragma solidity >=0.7.0 <0.9.0;
1010
// A function is a group of code that can be called anywhere within your program
1111
// Eliminating the possibility of writing thesame block of code many times
1212

13-
contract learnFunctions {
13+
contract LearnFunctions {
1414
// syntax
1515
// function functionName(parameter list) scope returns(return type) { statements }
1616

004-decision-making.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pragma solidity >=0.7.0 <0.9.0;
88
* based on certain conditions or decision made
99
*/
1010

11-
contract learnDecisionMaking {
11+
contract LearnDecisionMaking {
1212
// orange variable
1313
uint256 oranges = 5;
1414

005-variables-and-scope.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pragma solidity >=0.7.0 <0.9.0;
66
* Learn about variables and scope
77
*/
88

9-
contract learnVariableAndScope {
9+
contract LearnVariableAndScope {
1010
// state variable
1111
uint256 public data = 10;
1212

006-arithmetic-operators.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ pragma solidity >=0.7.0 <0.9.0;
44

55
/**
66
* Learn about arithmetic operators in solidity
7-
* operators tell the compiler to perform specific
7+
* Intro - Operators tell the compiler to perform specific
88
* mathematical operation, logical or relational
99
* operation and produce a suitable response
1010
*/
1111

12-
contract learnArithmeticOperators {
12+
contract LearnArithmeticOperators {
1313
uint256 public a = 5;
1414
uint256 public b = 10;
1515

007-comparison-operators.sol

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// SPDX-License-Identifier: GPL-3.0
2+
3+
pragma solidity >=0.7.0 <0.9.0;
4+
5+
/**
6+
* Comparison operators
7+
*/
8+
9+
contract ComparisonOperators {
10+
uint256 public a = 5;
11+
uint256 public b = 10;
12+
13+
function compareEquality() public view returns (bool) {
14+
return a == b; // evaluates to a boolean: true or false
15+
// return a != b; // not equal to
16+
}
17+
18+
function compareValues() public view returns (bool) {
19+
if (a > b) {
20+
return true;
21+
}
22+
return false;
23+
}
24+
25+
// require function
26+
function compareValuesUsingRequire() public view {
27+
require(a > b, "This is false.");
28+
}
29+
30+
function compareGreaterOrEqual() public view {
31+
require(a >= b, "This is false.");
32+
}
33+
}

008

Whitespace-only changes.

009

Whitespace-only changes.

010

Whitespace-only changes.

0 commit comments

Comments
 (0)