2

I've got a bit of a puzzle I need help to unravel here and I've been unable to find the answer here thus far ITL.

In this file: https://bitcoinj.googlecode.com/git/core/src/main/java/com/google/bitcoin/core/PartialMerkleTree.java

Appears the line: byte[] left = recursiveExtractHashes(height-1, pos*2, used, matchedHashes).getBytes(), right;

Which eclipse seems to think is valid Java and it compiles just fine..

So what exactly does the ", right" portion perform?

I think its a declaration but I've never seen a declaration like this one.

Can anyone elaborate further?

1 Answer 1

7

This declaration is equivalent to something like this:

int i = 0, j;

right is declared but not initialized as an array of bytes, whereas left is both declared and initialized.

Sign up to request clarification or add additional context in comments.

5 Comments

Not instantiated, merely declared. Instantiation will be when new is called.
@RealSkeptic Right. Vocab is getting rusty, haven't done a programming interview in a while. Fixing... (Thanks!)
Yes of course I see. I was distracted by the length and location of the assignment.
@Akumaburn Honestly, I think that code is poorly written for readability's sake. I would've left it as two separate lines. (Also, if you liked my answer, please accept it!) meta.stackexchange.com/questions/5234/…
Agreed about the readibility. It's good to be able to identify it, but I wouldn't emulate it if I were you.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.