1

I want to create an array of chars where some of the values are non-printable characters but not spaces: I tried:

a = ['a', 'b', \n]
a = ['a', 'b', '']
a = ['a', 'b', nothing]

without success.

sbac
  • 1,897
  • 1
  • 18
  • 31
  • 2
    Try changing `a = ['a', 'b', \n]` to `a = ['a', 'b', '\n']`. Beyond that, what non-printable characters do you seek to include ? – High Performance Mark Jun 24 '20 at 12:25
  • I want simply to create an array of length 3 but where one of the values is invisible (not a space) – sbac Jun 24 '20 at 12:32
  • 6
    What exactly do you mean by that? What is "visible" depends on printing. If you include something like a zero-width non-joiner, `\u200c`, it will still show _as the element of the array_. OTOH, if you `join` the array and `print` it, it will not be visible -- but so won't a newline, except for the fact that it starts a new line. Could you explain you actual goal? – phipsgabler Jun 24 '20 at 12:37
  • I have two arrays of chars: `A = ['a', 'b', 'c']` and `B = ['d', 'e']`. I want that both arrays have the same length (r) but I can't use `rpad` or `lpad` with spaces. The third value of `B` should be non-printable making both arrays have the same length. – sbac Jun 24 '20 at 12:50
  • I guess something like `["d", "e", ""]` _might_ behave how you want, but it's really hard to tell. – mbauman Jun 24 '20 at 21:11
  • @MattB.The problem is that I have an array of characters and not an array of strings. But I think I managed this problem with the '\n' solution. – sbac Jun 24 '20 at 22:08

0 Answers0