0

What is the difference between these two?

 _instance.send(msg.value);

 address(_instance).send(msg.value);

both of them are giving me the same result on remix. Why?

So is this:

address(this).balance;

this.balance;

Am I missing something. Is there security consideration in using one of these?

2

Those are not "two methods". When you do address(_instance) or address(this) what you are doing is casting the _instance/this object into the type address.

Casting means taking an object of a certain data type and converting it into another data type.

For example, if you had a uint8 number and you wanted to do a power operation with it, given that uint8 would not have the capacity to hold a very large number, you would first cast it into a bigger int like this: uint256(number)

In your example above, you are taking a contract object and casting it into an address, which basically gives you the address of the contract.

  • 1
    So both of them are the same and there is nothing to be bothered about? – Kashish Khullar Dec 29 '17 at 12:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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