The difference between print and puts as another way to declare the same thing, but not Perl's say too?

As far as I understand, just like Ruby,

puts ("Hello World")
print ("Another line")

are two alternative ways of doing the same thing: display a string on screen.
As far as versitality goes, since we already have the two methods, couldn’t Perl’s

say ("Or a third?")

also be made to work the same way (since we don’t need to worry about /n lines in neither Ruby, nor Crystal it’d just add to Crystal’s flexibility over Ruby for new learners coming from Perl’s, or Raku’s syntax…

Hi! puts and print are not the same. puts adds a newline after whatever you pass to it (unless it’s a string that ends with a newline), while print doesn’t add a newline.

Then, we don’t really like/want aliases in the language, so we won’t add say.

1 Like

Oh, so basically puts acts the same as say in Perl, and print in Python, by implicitly adding a newline after itself, whereas print in Crystal is that without a newline added, much like print acts in Perl… go it, much thanks.

1 Like