zlacker

[parent] [thread] 1 comments
1. sireat+(OP)[view] [source] 2021-10-28 11:08:58
I also fear that Copilot will be teaching anti-patterns.

Just tried something really simple: def is_palindrome

Copilot suggestion was

  def is_palindrome(word):
      if word == word[::-1]:
          return True
      else:
          return False
facepalm

So good for technically correct solution but still...

This is an anti-pattern I think in pretty much any language that I know of and something that about half of my beginning students try when they learn about branching..

UPDATE: more howlers along the same vein

  def haystack_contains_needle(haystack, needle):
      if needle in haystack:
          return True
      else:
          return False
replies(1): >>sireat+ZL
2. sireat+ZL[view] [source] 2021-10-28 16:02:11
>>sireat+(OP)
UPDATE: The above howlers were in IntelliJ...

However in Visual Studio Code on a different computer, I got much better idiomatic suggestions.

such as

  def is_palindrome(word):
      return word == word[::-1]
Very puzzling.
[go to top]