Algorithm2e : 1 block without vline

algorithm2evertical alignment

I'm trying do define a block without vertical line in Vline mode. For example in :

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[ruled]{algorithm2e}
\begin{document}
\begin{algorithm}
    \SetKwBlock{Init}{Initialize}{}
    
    \Init{
        x $\leftarrow$ 3\;
        \eIf{a=b}{
            y $\leftarrow$ 5\;  
        }{
            y $\leftarrow$ x\;
        }
    }
\end{algorithm}
\end{document}

Wrong result

I would like to keep the vertical line in the ifelse statement but remove it in the Initialize statement.
Is that possible ?

NB : Another way to do it may be to look for a way to indent part of the text but ii does not work in my case because indenting the text does not indent the vertical line in the ifelse statement.
Thanks in advance, I'm new to this section of StackExchange.

Best Answer

You can delay switching on the lines until after your \Init:

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[ruled,noline]{algorithm2e}
\begin{document}
\begin{algorithm}
    \SetKwBlock{Init}{Initialize}{}
    \Init{
        x $\leftarrow$ 3\;
        \SetAlgoLined
        \eIf{a=b}{
            y $\leftarrow$ 5\;  
        }{
            y $\leftarrow$ x\;
        }
    }
  \SetAlgoNoLine
\end{algorithm}
\end{document}

enter image description here