Elon Musk left court in LA on Tuesday night after answering more than four hours of questions.

The Tesla chief executive is accused of defaming one of the heroic British divers involved in the daring rescue of a team of young Thai footballers from a flooded cave in 2018.

Musk doesn’t deny he wrote a tweet using the abusive term ‘pedo guy’ after seeing a TV interview given by Vernon Unsworth following the rescue.

The billionaire entrepreneur said he was upset that, unprovoked, Unsworth had criticised efforts by a team of his Space X engineers to build a mini-sub to get the boys out. Mr Unsworth claimed it was a PR stunt.

Musk was, at times, faltering in his answers, as he skimmed through pages of court papers in huge arch files, looking puzzled by the lawyer’s line of questioning.

There were moments when the court broke out in to laughter - like when Musk was elaborating on the professional conman who approached him offering to dig dirt on Mr Unsworth.

"We were tricked," he said, "as a professional conman he was quite convincing".

Vernon Unsworth, left, attends court. Credit: AP

Later he was quoted a tweet he’d written suggesting he hoped Mr Unsworth would sue him. "Be careful what you wish for," he joked grimly.

The second day of the trial will see more questions for Musk, and likely the first evidence from the man suing him.

Expect a lot of discussion about exactly what you can tweet with out facing the consequences of the law in the days to come.