Grant Allen’s essay “The Milk in the Cocoa-Nut” provides a rather laborious answer to the popular conundrum about how the milk got into the coconut in the first place. Right at the start of his essay Allen states:
For many centuries the occult problem how to account for the milk in the cocoa-nut has awakened the profoundest interest alike of ingenious infancy and of maturer scientific age.
Grant Allen in Popular Science Monthly (1884), May, p. 50
This was considered one of a number of stock conundrums in the late nineteenth century:
It would be a curiosity to see the names of the men in public life, to-day, who started out and received their first encouragement by discussing the somewhat fresh and novel questions: "Whether Columbus was entitled to more credit for discovering America, than Washington was for defending it"; "whether there is greater pleasure in participation than in anticipation"; "which is the more perplexing, a smoky chimney or a scolding wife"; "which could more easily be dispensed with, fire or water"; and last but not least: "How did the milk get into the cocoanut shell?"
Transactions of the Wisconsin State Agricultural Society (1873), vol. 11, p. 250
But it had already become a popular witticism at least forty years before:
... when that fat fiddle-player, George Prince Regent, inquired of an old dowager of eighty-six, at what age woman became insensible to the tender passion, he received the following simpering reply: - "Your Royal Highness had better apply to someone older than myself for an answer to that question," which fully accounts for the milk in the cocoanut, as the showmen say.
The Satirist; or, the Censor of the Times (1832), 19 August, p. 269
The attribution of the expression to showmen here suggests that it was considered at least ostentatious if not plain vulgar at the time. Its appearance in a London publication casts considerable doubt on the American origin claimed by some slang dictionaries, though much of the early evidence for the expression does derive from America.
In 1904 this way of expressing that one had gained a sudden insight into the true nature of a thing or a situation clearly betrayed a lack of refinement on the part of the speaker:
I have led you through a very sandy desert. But now, if I may be allowed so vulgar an expression, we begin to taste the milk in the cocoanut.
William James, "Pragmatism’s Conception of Truth" in The Journal of Philosophy (1907),vol. 4, p. 148
In an early draft of the Cyclops episode (V.A. 6) the phrase is used in a different context from the published text: the milk in the coconut being that Bloom is exposed as a calculating hunter for Mrs Riordan’s legacy. Joyce eventually transferred the phrase into the interior monologue of the vicious I-narrator when Boylan is revealed as manager of the concert tour involving Molly Bloom, and added an unmistakable sexual innuendo, not least with the second part of the phrase (“and the absence of hair on the animal’s chest”), which has proved so elusive to commentators on Ulysses.
This turns out to be an as-yet undocumented version of the standard form (“but not for the hair outside”) not infrequently added to the first part of the idiom and popularised in publications as diverse as parliamentary proceedings and Punch:
I have been unable to discover whether it was George Selwyn, Machiavelli, or the Arabian physician Avicenna, who made use of the remarkable expression, "That accounts for the milk in the cocoa-nut; but not for the hair outside."
"The Victorian Parliament Legislative Assembly, Thursday January 12" in Argus, (Melbourne: 1860), 13 January
"My faith," said Lord JOHN, "I am getting tired of this. Shall we never reach the Sun?"
"Courage, my friend," was the well-known reply of the brave little Doctor. "We deviated from our course one hair's-breadth on the twelfth day. This is the fortieth day, and by the formula for the precession of the equinoxes, squared by the parallelogram of an ellipsoidal bath-bun fresh from the glass cylinder of a refreshment bar, we find that we are now travelling in a perpetual circle at a distance of one billion marine gasmeters from the Sun. I have now accounted for the milk in the cocoa-nut."
"But not", said the Philosopher, as he popped up through a concealed trap-door, "for the hair outside. That remains for another volume."
"Mr Punch’s Prize Novels" in Punch (1891), vol. 100, p. 85