Skip to content

Commit

Permalink
arithmetic operations on different types
Browse files Browse the repository at this point in the history
  • Loading branch information
sinalalebakhsh committed Oct 26, 2023
1 parent 418c158 commit e2f8851
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion features/SingleDefinitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ var OriginSingleDef = SingleDefinitions{
"basic operator": "Go supports many standard arithmetic operators. EXAMPLE: + , - , / , % . For integer division, the remainder is dropped (e.g. 5 / 2 == 2).",
"basic operators": "Go supports many standard arithmetic operators. EXAMPLE: + , - , / , % . For integer division, the remainder is dropped (e.g. 5 / 2 == 2).",
"converting between types": "Converting between types is done via a function with the name of the type to convert to. ",
"";"",
"arithmetic operations on different types": "In many languages you can perform arithmetic operations on different types of variables, but in Go this gives an error. ",
},
}

Expand Down
17 changes: 17 additions & 0 deletions features/SingleDefinitionsExamples.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,25 @@ func CelsiusFreezingTemp() int {
f := float64(x) // f has type float64 (ie. 42.0)
var y float64 = 11.9 // y has type float64
i := int(y) // i has type int (ie. 11)`,
"arithmetic operations on different types":`var x int = 42
// this line produces an error
value := float32(2.0) * x // invalid operation: mismatched types float32 and int
// you must convert int type to float32 before performing arithmetic operation
value := float32(2.0) * float32(x)`,

"arithmetic operations on different type":`var x int = 42
// this line produces an error
value := float32(2.0) * x // invalid operation: mismatched types float32 and int
// you must convert int type to float32 before performing arithmetic operation
value := float32(2.0) * float32(x)`,


},

}


6 changes: 3 additions & 3 deletions mergeToMain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
echo -n "Git push on branch develop "
echo ""
git add .
git commit -m " converting between types "
git commit -m " arithmetic operations on different types "
git push -u origin develop
echo "====================================================================="
echo -n "git checkout beforeMergeToMain "
Expand All @@ -16,7 +16,7 @@ echo "====================================================================="
echo -n "Git is Push for beforeMergeToMain "
echo ""
git add .
git commit -m " converting between types "
git commit -m " arithmetic operations on different types "
git push -u origin beforeMergeToMain
echo "====================================================================="
echo -n "git checkout main "
Expand All @@ -34,7 +34,7 @@ echo "====================================================================="
echo -n "Git is Push for main "
echo ""
git add .
git commit -m " converting between types "
git commit -m " arithmetic operations on different types "
git push -u origin main
echo "====================================================================="
echo -n "git checkout develop "
Expand Down

0 comments on commit e2f8851

Please sign in to comment.