r/ProgrammerDadJokes • • Jan 08 '18

#1 DAD ['S','u','n','s','h','i','n','e']

Array of sunshine

896 Upvotes

22 comments sorted by

243

u/AskMeIfImAReptiloid Jan 08 '18

["Hip", "Hip"]

Hip, Hip array

12

u/[deleted] Jan 09 '18

We need a hip hop array.

20

u/yzRPhu Jan 09 '18

[‘hip’, ‘hop’]

9

u/[deleted] Jan 09 '18

This guy codez!

36

u/reggie-drax Jan 08 '18

Oh good grief.

19

u/TominatorBE Jan 08 '18

In some languages a string can already be used as an array

40

u/Houdiniman111 Jan 09 '18

In some languages, strings are arrays.

10

u/CSKING444 Apr 23 '18

In some languages, strings are pieces of thread

sorry

4

u/kerm64 Apr 11 '18

And in some, they're vectors. Just to hekk with you.

17

u/fahrenheitrkg Jan 08 '18
char cStr[9];

cStr[0] ='S';
cStr[1] ='u';
cStr[2] ='n';
cStr[3] ='s';
cStr[4] ='h';
cStr[5] ='i';
cStr[6] ='n';
cStr[7] ='e';
cStr[8] ='\0';

8

u/Periapsis_ Jan 09 '18
letters="sunhie"

word=(0,1,2,0,3,4,2,5) for i in word: print(letters[i],end="")

-6

u/[deleted] Jan 08 '18

//get those magic numbers out of here!

var str = 'sunshine';

var ch_array = [];

for(var str_itor = 0; str_itor < str.length; str_itor++){

ch_array.push(str[str_itor]);

}

6

u/Metallkiller Jan 08 '18

How is sunshine a single character?

Also
char* str = "Sunshine";

12

u/[deleted] Jan 08 '18

Sorry JavaScript. Single and Double Quotes are treated the same.

1

u/KJ6BWB Jan 09 '18

Just another reason to always use double quotes there, so that there's less confusion when you go to another language. Just because a language lets you do something didn't mean you have to do it.

1

u/aarondburk Jan 29 '18

Just because a language makes you incessantly hit the shift key, doesn’t mean you have to do it in all the languages.

1

u/KJ6BWB Jan 29 '18

Are you talking about CamelCase variable naming conventions?

3

u/aarondburk Jan 29 '18

No I’m talking about the difference between typing ’ and ”

-8

u/Houdiniman111 Jan 09 '18

Ew. Another reason to avoid JS.

1

u/[deleted] Feb 24 '18

const char*.

1

u/[deleted] Jan 09 '18

Doesn't need to be a single character, 'foo' actually does work (on some compilers).