[Solved] Define same environment with different amount of parameters

Titanlord Asks: Define same environment with different amount of parameters
I want to define two versions of the environment begin{mainbox} end{mainbox}, depending if I provide zero or one parameter. I want to use them like this:

Code:
begin{mainbox}
    stuff
end{mainbox}
begin{mainbox}{title}
    stuff
end{mainbox}

The definition of the mainboxes looks like this:+

Code:
documentclass{article}
usepackage{amsthm}
usepackage{thmtools}
newenvironment{mainbox}[1]{
    thmbox[M]{textbf{#1}}
    hspace*{-1.9em}slshapeignorespaces
    normalfont
}
{
    endthmboxvspace*{.75ex}
}
newenvironment{mainbox*}{
    thmbox[M]{$ $hspace{33.75pt}$ $}
    hspace*{-1.9em}slshapeignorespaces
    normalfont
}
{
    endthmboxvspace*{.75ex}
}

In both cases I want to create a box. The one with no parameter has no title, the one with the parameter has a title. One fix is to give them differen names, like mainbox and mainbox*, but I tought there must be a more elegant way. Can someone help me?

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.