Reputation: 11
I am new on stackowerflow and also solidity.
I have to do: In function booleanOperatorTest
, negate the variable foo
and assign the result to variable negation
pragma solidity ^0.4.17;
contract OperatorTutorial {
function booleanOperatorTest(bool foo, bool bar) public pure
returns (bool negation, bool conjunction, bool disjunction, bool equality, bool inequality) {
// Negate the variable "foo" and assign the result to variable "negation"
// negation =
}
I tried everything but i can't pass this step, please help, thank you .
Upvotes: 0
Views: 284
Reputation:
pragma solidity ^0.4.17;
contract OperatorTutorial {
function booleanOperatorTest(bool foo, bool bar) public pure
returns (bool negation, bool conjunction, bool disjunction, bool equality, bool inequality) {
// Negate the variable "foo" and assign the result to variable "negation"
// negation =
negation = !foo;
// Use logical "and" on variables "foo" and "bar" and assign the result to variable "conjunction"
// conjunction =
conjunction = (foo && bar);
// Use logical "or" on variables "foo" and "bar" and assign the result to variable "disjunction"
// disjunction =
disjunction = (foo || bar);
// Make sure variable "equality" is true when "foo" and "bar" are equal and is false otherwise.
// equality =
equality = (foo == bar);
// Make sure variable "inequality" is true when "foo" and "bar" are not equal and is false otherwise.
// inequality =
inequality = (foo != bar);
}
Upvotes: 0
Reputation: 11
pragma solidity ^0.4.17;
contract OperatorTutorial {
function booleanOperatorTest(bool foo, bool bar) public pure
returns (bool negation, bool conjunction, bool disjunction, bool equality, bool inequality) {
negation = !foo;
}
Thanks to Mert Sungur
Upvotes: 1
Reputation: 38
Example function:
function booleanOperatorTest(bool foo, bool bar) public pure
returns (bool negation,bool conjunction) {
// Negate the variable "foo" and assign the result to variable "negation"
negation =foo;
conjunction = (foo && bar);
...
}
Upvotes: 0