What is the difference between code cell and input cell?
1 Answer
TLDR:
- Code is the default one in .wl .m files, content of Input in those cases will be commented so it won't run with
<< my.wl
( more: 9921 - Input does a little formatting, auto indents, line wrap etc., in Code it is what you type.
- Code is an InitializationCell so it will or ask you about evaluating it before you run anything in a fesh notebook. Could be nice or annoying, depending on your workflow.
Personal note, I prefer to control my formatting, don't care about 2D input and am annoyed by 'evaluate initialization cells prompt' so I work with .wl files with Code cells on daily basis.
Differences:
styles = {CurrentValue[{StyleDefinitions, "Code"}], CurrentValue[{StyleDefinitions, "Input"}]};
{ Complement @@ styles, Complement @@ Reverse@styles } //
KeyUnion // Normal // Transpose //
Map[
{ #[[1, 1]]
, #[[1, 2]] /. m_Missing :> CurrentValue[{StyleDefinitions, "Code", m[[2]]}]
, #[[2, 2]] /. m_Missing :> CurrentValue[{StyleDefinitions, "Input", m[[2]]}]
} &
] //
Sort // Prepend[{"", "Code", "Input"}] //
Grid[#, Alignment -> Left, Background -> {{}, {{[email protected], None}}},
Dividers -> {{2 -> True}, {2 -> True}}] &
-
$\begingroup$ Thank you. Is there any official recommendation from Wolfram which tone to use when? $\endgroup$ Feb 25 at 22:55
-
-