wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
const b; | const b = 93; | Initialize const. | JavaScript |
function bar() {{
return
{{key:'hello'}}
}} | function bar() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
let text = String::from("value"); let r=&text; text.push_str("!"); | let mut text = String::from("value"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
if x = 65: | if x == 65: | Use == for comparison. | Python |
{{"id":"value" "value":28}} | {{"id":"value", "value":28}} | Add comma. | JSON |
if ($x = 3) | if ($x == 3) | Use ==. | Perl |
if (x = 3) {{}} | if (x === 3) {{}} | Use === for equality. | JavaScript |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
for (int i=0; i<16; i++) {{}} | for (int i=0; i<16; i++) {{}} | Correct. | Java |
id: message
status: hello, | id: message
status: hello | Remove comma. | YAML |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
let b = 23; | let b = 23; | Correct. | JavaScript |
values[100] | if (length(values) >= 100) values[100] | Check length. | R |
if y = 61 | if y == 61 | Use ==. | Ruby |
echo result world | echo 'result world' | Quote to prevent splitting. | Shell |
foo == '12' | foo === 12 | Use strict equality. | JavaScript |
String data = 'value'; | String data = "value"; | Double quotes. | Java |
def bar(a):
return a + 1 | def bar(a):
return a + 1 | Correct. | Python |
if [ $num = 65 ]; then | if [ "$num" = 65 ]; then | Quote variable. | Shell |
for a in range(86)
print(a) | for a in range(86):
print(a) | Colon after for. | Python |
int[] items = new int[27];
items[27] = 5; | int[] items = new int[27];
if (27 < items.length) items[27] = 5; | Check bounds. | Java |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
'result' + 56 | 'result' + 56.to_s | Convert int. | Ruby |
UPDATE orders SET status='test' WHERE status=13 | UPDATE orders SET status='test' WHERE status=13; | Add semicolon. | SQL |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if (temp = 13) | if (temp == 13) | Use ==. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
var x int = 'output' | var x string = 'output' | Type mismatch. | Go |
if num > 11
print('result') | if num > 11:
print('result') | Colon missing after if. | Python |
let z = 'info' | let z = "info" | Double quotes. | Swift |
$values[61] | if ($values.Count -gt 61) {{ $values[61] }} | Check bounds. | PowerShell |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
compute | compute() | Add parentheses. | Swift |
if a = 84 | if a == 84 | Use ==. | Go |
if (c = 96) | if (c == 96) | Use ==. | R |
def compute():
print('value') | def compute():
print('value') | Indent function body. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
my @arr = (29,69,13); | my @arr = (29,69,13); | Correct. | Perl |
WHERE name = '53' | WHERE name = 53 | Don't quote integer. | SQL |
class User {{ int num; }}
obj.num=5; | class User {{ public int num; }}
obj.num=5; | Make field public. | Java |
<p>message <b>world</p></b> | <p>message <b>world</b></p> | Nest properly. | HTML |
let item: number | null = null; item.toFixed(71); | let item: number | null = null; if(item!==null) item.toFixed(71); | Null check. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(28); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(28, () => console.log('listening')); | Add callback. | Node.js |
if (count = 88) {{}} | if (count == 88) {{}} | Use ==. | Java |
if data = 5 {{}} | if data == 5 {{}} | Use ==. | Swift |
DELETE FROM orders WHERE name=22 | DELETE FROM orders WHERE name=22; | Add semicolon. | SQL |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
if ($count = 67) {{}} | if ($count -eq 67) {{}} | Use -eq. | PowerShell |
index = 99 | index=99 | No spaces. | Shell |
SELECT * FROM items WHRE email=17; | SELECT * FROM items WHERE email=17; | Fix WHERE. | SQL |
jwt.sign({{id:42}}, 'secret'); | jwt.sign({{id:42}}, 'secret', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
list[31] | if list.indices.contains(31) {{ list[31] }} | Check index. | Swift |
val bar = 'value' | val bar = "value" | Double quotes. | Kotlin |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
else
print('message') | else:
print('message') | Colon after else. | Python |
84bar = 10 | bar84 = 10 | Variable cannot start with digit. | Python |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
'value' + 34 | 'value' + str(34) | Can't add int to string. | Python |
h1 {{ font-size:10px color:#333; }} | h1 {{ font-size:10px; color:#333; }} | Add semicolon. | CSS |
val val: Int = 'hello' | val val: String = 'hello' | Fix type. | Kotlin |
def compute
puts 'result'
end | def compute
puts 'result'
end | Correct. | Ruby |
print('value') | print('value') | Correct. | R |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
[47, 55, 21 | [47, 55, 21] | Close bracket. | Python |
disp('info') | disp('info') | Correct. | MATLAB |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let text1 = String::from("output"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
[71, 75, 13 | [71, 75, 13] | Close bracket. | Ruby |
// comment | /* comment */ | Use /* */. | CSS |
values(32) | if length(values) >= 32, values(32), end | Check length. | MATLAB |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
["result", 36] | ["result", 36] | Correct. | JSON |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
if data = 50 | if data == 50 | Use ==. | MATLAB |
if (count = 35) {{}} | if (count == 35) {{}} | Use ==. | Kotlin |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
x := 79 | x := 79 | Correct. | Go |
x = data | x = 'data' | Quote strings. | Python |
'99' + 7 | 99 + 7 | Avoid string coercion. | JavaScript |
function handle() {{ echo 'value'; }} | function handle() {{ echo 'value'; }} | Correct. | PHP |
let num: i32 = "output"; | let num: &str = "output"; | Type mismatch. | Rust |
const user:Person = {{name:'test'}}; | const user:Person = {{name:'test', age:18}}; | Add missing property. | TypeScript |
function process(): void {{ return 18; }} | function process(): number {{ return 18; }} | Return type mismatch. | TypeScript |
class User {{ int y; }}; | class User {{ public: int y; }}; | Make public. | C++ |
function bar(val:string){{return val;}} bar(35); | function bar(val:string){{return val;}} bar('world'); | Pass correct type. | TypeScript |
{{'age':22, 'title' 5}} | {{'age':22, 'title':5}} | Colon missing. | Python |
let a: number = 'message'; | let a: string = 'message'; | Fix type. | TypeScript |
$val = 21; if ($val = 21) {{}} | $val = 21; if ($val == 21) {{}} | Use ==. | PHP |
let mut item=86; let ref1=&mut item; let ref2=&mut item; | let mut item=86; {{ let ref1=&mut item; }} let ref2=&mut item; | Only one mutable borrow. | Rust |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
int arr[93]; arr[93]=5; | int arr[93]; if(93<93){{}} else arr[93]=5; | Bounds check. | C++ |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
arr.forEach(function(val) {{ console.log(val); }}) | arr.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.