Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lua convert userdata to string

Tags:

torch

lua

I'm trying to print out some userdata as a string, but the documentation for lua pretty weak to nonexistant. How do I convert a userdata variable to a string so that I can write it to a file?

like image 733
Soubriquet Avatar asked Sep 03 '25 06:09

Soubriquet


1 Answers

tostring(userdata)

Creator of that userdata must provide __tostring metamethod.

like image 143
FareakyGnome Avatar answered Sep 05 '25 00:09

FareakyGnome