2

I am trying to compile the following code:

pragma solidity ^0.5.1;

contract MKotET1_1{
   address payable king; uint public claimPrice = 100;

   function calculateCompensation() public returns(uint) {
}

function( ) external payable {
   if (msg.value  < claimPrice) revert();
      uint compensation = calculateCompensation();
      (bool success, bytes memory returnMessage) = 
      king.call.value(compensation)("");
      require(success); 
      king = msg.sender;
   }
}

I am getting following warning message:

solc MKotET_stackExchange.sol MKotET_stackExchange.sol:11:26: Warning: Unused local variable. (bool success, bytes memory returnMessage) = king.call.value(compensation)(""); ^------------------------^

Somebody please guide me how to remove this warning message.

Zulfi.

2
  • Why do you want to silence the warning?
    – user19510
    Jun 22, 2019 at 18:33
  • Contract owner won't like it. Also warning means something wrong going on, not good from software engineering point of view
    – zak100
    Jun 22, 2019 at 18:59

1 Answer 1

4

You do not need to explicitly state the second variable declaration. You can write it as follows:

(bool success, ) = king.call.value(compensation)("");
require(success); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.