No Inline Comments But Normal Explanations

Whatever I prompt to make ChatGPT not include inline comments in code, it will also turn off all explanations of the code outside the code block. It’s like they’re linked and I can’t get one without the other. Is there a way to just get clean code without lines after #, but still have it explain the code normally?

Hi,

This works for me :slight_smile:

“return some php code to return first primes to 100, do not include comments outside code but do in code”

function getPrimes($limit) {
$primes = ;
// Loop through numbers from 2 to the limit
for ($i = 2; $i <= $limit; $i++) {
$isPrime = true;
// Check if $i is divisible by any number up to sqrt($i)
for ($j = 2; $j <= sqrt($i); $j++) {
if ($i % $j == 0) {
$isPrime = false; // $i is not prime
break;
}
}
// If still prime, add to the list

OR

“return some php code to return first primes to 100, include an explanation but no comments in code”

Here’s the PHP code that returns prime numbers up to 100:

function getPrimes($limit) {
$primes = ;
for ($i = 2; $i <= $limit; $i++) {
$isPrime = true;
for ($j = 2; $j <= sqrt($i); $j++) {

Is there a specific example that you are trying?

2 Likes