I had no idea that `verb` or `verbatim` are not allowed inside `\ifbool` check. This makes it very limited.

I needed to generate code based on a flag. The code to generate happened to have small part of it which uses `\verb`. I am getting an error because of this.

I looked at [documentation](http://ctan.sharelatex.com/tex-archive/macros/latex/contrib/etoolbox/etoolbox.pdf) for the `etoolbox` but did not see something so far to help me with this.

Is there a way to use `\verb` as follows

```
\documentclass[11pt]{scrbook}%
\IfFileExists{luatex85.sty}{\usepackage{luatex85}}{}
\usepackage{etoolbox} 
\newbool{private}
\setbool{private}{true}

\begin{document}

\ifbool{private}
{
This is \verb|test|  %how to make this work?
}%
{
This is the other case
}
\end{document}

```

Compile

```
lualatex db.tex 
This is LuaTeX, Version 0.95.0 (TeX Live 2016) 
 restricted system commands enabled.
(./db.tex
LaTeX2e <2016/03/31> patch level 2
Babel <3.9r> and hyphenation patterns for 1 language(s) loaded.
(/usr/local/texlive/2016/texmf-dist/tex/latex/koma-script/scrbook.cls
Document Class: scrbook 2016/06/14 v3.21 KOMA-Script document class (book)
(/usr/local/texlive/2016/texmf-dist/tex/latex/koma-script/scrkbase.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/koma-script/scrbase.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/koma-script/scrlfile.sty
Package scrlfile, 2016/06/14 v3.21 KOMA-Script package (loading files)
                  Copyright (C) Markus Kohm

))) (/usr/local/texlive/2016/texmf-dist/tex/latex/koma-script/tocbasic.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/koma-script/scrsize11pt.clo)
(/usr/local/texlive/2016/texmf-dist/tex/latex/koma-script/typearea.sty
Package typearea, 2016/06/14 v3.21 KOMA-Script package (type area)
                  Copyright (C) Frank Neukam, 1992-1994
                  Copyright (C) Markus Kohm, 1994-

)) (/usr/local/texlive/2016/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(./db.aux)

! LaTeX Error: \verb ended by end of line.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.14 }

? 

```

TL 2016 

---

**Update**

Thanks to answers below. 
I have to use `\newbool{private}\setbool{private}{true}` since I set up these already using complicated pre-processing (I read this flag from file during build., etc... and I did not want to change all this code, as it is automated) but with the help of the answers, I found a workaround which allows me to use my current boolean and also use `\newif` to go around this limitation. Here is the final code 

```
\documentclass[11pt]{scrbook}%
\usepackage{etoolbox} 

\newbool{private}
\setbool{private}{true}%in actual application, this only set at compile time
              %from reading a file based on makefile command line
              %setting. So it is not hardcoded in the Latex file as shown
              %in this MWE. This is just an example.
\newif\ifprivate

\ifbool{private}{\privatetrue}{\privatefalse}

\begin{document}

\ifprivate
  This is \verb|test|  
\else 
  This is the other case
\fi 

\end{document}

```