Programming
No Operation(no-op, nop, noop)
신잼
2022. 1. 11. 11:03
delete는 builtin 함수로 아래와 같이 나와 있는데 no-op가 궁금해서 찾아봤다.
// The delete built-in function deletes the element with the specified key
// (m[key]) from the map. If m is nil or there is no such element, delete
// is a no-op.
func delete(m map[Type]Type1, key Type)
Unnecessary guard around call to delete
아래와 같이 map에 key가 있는지 채크하고 있으면 지우는 코드를 짰을 때 그렇게 할 필요 없다고 staticcheck에서 알려준다.
sampleMaps := []map[string]int
for _, sampleMap := range sampleMaps {
if _, ok := sampleMap["wow"]; ok {
delete(sampleMap, "wow")
}
}
No Operation
컴퓨터 과학에서 NOP 또는 NOOP(No Operation)은 어셈블리어의 명령, 프로그래밍 언어의 문, 컴퓨터 프로토콜 명령의 하나로, 아무 일도 하지 않는다 - wiki
명령어 수행부분에서 CPU에게 잠시 쉬어가도록 지정하는 것
언어별 nop
C언어
세미콜론(;) 혹은 빈 블럭({})
jQuery
jQuery.noop() 함수
Perl
ellipis 구문(...)
Python
pass 구문
Reference
반응형